progNewbie progNewbie - 1 year ago 148
Android Question

How to serialize ArrayList<Object> to String in Java Android

This question was asked many times, but I haven't found a good solution yet.
I want to store my Arraylist in the sharedpreferences in Android as a String. So how can I serialize and deserialize it?

Any solutions?

Answer Source

Try using Gson Library this way:

String json = new Gson().toJson(<your list>);

To add Gson library add to dependencies

compile ""
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download