In continuation to the previous tutorial Android Post Data Using Retrofit  we will be fetching data using same retrofit library. Retrofit library is considered to be the fastest library so we will be using it.

Now we will be fetching data that we have posted previously refer the previous tutorial to get more info.

 

Add Retrofit to your project

Build.Gradle(Module:App)

activity_main.xml

Add four fields to display the values

 

Api.java

Create a api file and specify the path here, also configure your Pojo file with it.

**GET parameter to fetch data

**POST parameter to post data

 

Details_Pojo.java

And now here come Pojo file which is used to serialize and deserialize the variables.

 

 

MainActivity.java

Using a Retrofit builder fetch the values

 

Initialize api class

 

Fetching the values into Pojo file

 

Now call method, success and failure conditions are specified here…

 

After getting succeeded set the values to fields as you wish as of example i am making it in simple way

 

 

If failure i am displaying a toast

 

Full code

 

ManifestActivity.xml

Mention INTERNET and ACCESS_NETWORK_STATE here

 

 

 

Output

Show Buttons
Hide Buttons
Read previous post:
Android Tutorial on Retrofit Library || Post Data Using Retrofit Http Library

Close