Skip to main content

Posts

Showing posts from September, 2017

Json Parsing Using Retrofit Library

1] Add Libraries in Gradle(module.app) in  dependencies compile 'com.squareup.retrofit2:retrofit:2.3.0' compile 'com.squareup.retrofit2:converter-gson:2.3.0' 2]Create APIClient.java public class APIClient { private static final String BASEURL1 = "https://finddata.com" ; //contacts/ public static Retrofit getClient() { Retrofit retrofit = new Retrofit.Builder() .baseUrl( BASEURL1 ) .addConverterFactory(GsonConverterFactory. create ()).build(); return retrofit; } } 3]Create APInterface public interface APInterface { @GET ( "finddata/api/fetch.php" ) Call<Result> getUser( @Query ( "results" ) int result, @Query ( "number" ) int num @Query ( "number" ) int num1 ); } 4]Do in MainActivity.java private void getData() { APInterface api=APIClient. getClient ().create(APInterfa...