Android app dealing with web services generally uses json links to parse the data known as json parser using with different types of libraries such as Volley Library, Retrofit and many more..

Parsing a json URL will get the details from the link provided called as api, so today we will see how to parse a json url locally within our app.Sometimes when we are about to test any services we will use this type of local json url to form the complete app structure before we implement json services.

When we have to parse data to populate in a listview we send data in arraylist.

[
{
"name":"abhi","phone":9876543210},
{
"name":"ravi","phone":1234567890},
{"name":"kishore","phone":3654789120},
{"name":"vishal","phone":1234567890},
{"name":"jai","phone":5478963215}
]

for more info

 

Also we some time json is used to send a simple set of data just like user information to be displayed in profile as user name, number, age, password.

[
{
"name":"kalyan","phone":9876543210,"age":30,"email":"kalyan@email.com"}
]

 

Create a raw json file in assets folder

Example json file

 

Then create a Pojo class

DetailsListPojo

 

and fetch the key values from the details list

Detail

 

Now designing the Android Reyclerview row

activity_details_row

Name and age of the user is shown in the list so we add two textview for the following fields as

 

 

Then we add recyclerview to the activity_main

activity_main

 

Now lets make a RecycleView Adapter

 

DetailsListAdapter

MainActivity

Parse the local json to fetch the user details

then

 

 

Output

Share our tutorial if you like, for more android tutorials.

Show Buttons
Hide Buttons
Read previous post:
Android Search RecyclerView

Close