I have an requirement to save the contents of a list in an activity so that the next t开发者_如何学Goime I open up that activity, the list values that are already added still persist. I also want to be able to access the contents of the List at any point in my application.
Apparently sharedPreferences only allow me to save Strings and I want to save String arrays. What is the best way to achieve this?
[Are databases the only way out of this??]
I always "pack" bigger things to JSON, in your case JSON Array may be the best idea.
So you will move data from the list to JSONArray, store it where you like, and when it will be needed you will read it as JSONArray (as all JSON objects it is serializable to String) and will build your list from it. Or if you can you may even use this JSONArray instead of converting this to list.
精彩评论