Reputation: 5821
In what format should i save the JSON data i get from a server in order to populate them later in a ListView ?
Is a 2 dimensional array enough or is there a better solution?
Every JSON Object is like :
{"id":"1","title":"London"}
Upvotes: 1
Views: 155
Reputation: 1154
You can use:
Arraylist<ClassName> jsondata=new ArrayList<ClassName>
Here's an example:
public Class ClassName
{
string fname;
string lname;
public void setfname(String fname)
{
this.fname=fname;
}
public void setlname(String lname)
{
this.lname=lname;
}
public String getlname(String lname)
{
return lname;
}
public String getfname(String fname)
{
return fname;
}
You can store it like this..
Upvotes: 3
Reputation: 1978
Where do you want to save the data? If it's in a preferences object then the JSON itself is a good option. Otherwise a HashMap
would be appropriate, and much better than the two-dimensional array: faster, more logical, better suited.
Upvotes: 1