you could write it simply as a csv file, like this,
1,name,desc
2,name2,desc2
3,name3,desc3
...
or you could use gson
library - http://code.google.com/p/google-gson/, to convert it into a json
string and then write it to a file, that way when you read it you could directly get the object from json
,
i would personally use the second method,
Edit: for writing to csv
try
{
FileWriter writer = new FileWriter("<path>/MyFile.csv");
while(lst.next())
{
for(int i = 0; i < columnSize; i++)
{
writer.append(i);
writer.append(',');
writer.append(lst.get(i).getName());
writer.append(',');
writer.append(lst.get(i).getDesc());
}
writer.append('\n');
}
}
catch(Exception e)
{
e.printStackTrace();
}
(assuming the object in side the ArrayList has methods getName()
and getDesc()
)
this might be helpful in reading it again,
Get and Parse CSV file in android