@Michael Dadi -If anyone could explain how to do this, it would really help.
I just explain you to way to archive this task
First of all, make POJO or Model class from JSON it will be an easy
{
"animalList": [
{
"animalName": "cat",
"animalFactList": [
{
"fact": "this ia fun fact of cat one"
},
{
"fact": "this ia fun fact of cat two"
}
],
},
{
"animalName": "dog",
"animalFactList": [
{
"fact": "this ia fun fact of dog one"
},
{
"fact": "this ia fun fact of dog two"
}
],
},
{
"animalName": "xyz",
"animalFactList": [
{
"fact": "this ia fun fact of xyz one"
},
{
"fact": "this ia fun fact of xyz two"
}
],
}
],
}
Here is a model class from JSON
public class Animal {
private List<AnimalListBean> animalList;
public List<AnimalListBean> getAnimalList() {
return animalList;
}
public void setAnimalList(List<AnimalListBean> animalList) {
this.animalList = animalList;
}
public static class AnimalListBean {
/**
* animalName : cat
* animalFactList : [{"fact":"this ia fun fact of cat one"},{"fact":"this ia fun fact of cat two"}]
*/
private String animalName;
private List<AnimalFactListBean> animalFactList;
public String getAnimalName() {
return animalName;
}
public void setAnimalName(String animalName) {
this.animalName = animalName;
}
public List<AnimalFactListBean> getAnimalFactList() {
return animalFactList;
}
public void setAnimalFactList(List<AnimalFactListBean> animalFactList) {
this.animalFactList = animalFactList;
}
public static class AnimalFactListBean {
/**
* fact : this ia fun fact of cat one
*/
private String fact;
public String getFact() {
return fact;
}
public void setFact(String fact) {
this.fact = fact;
}
}
}
}
it will store your data temporary while app close u will lost all data
so you can use any database for saving data in the local device.
now you can set adapter using this Animal.class in recyclerview
.