I have one listView in my app, which i is use to list the differnt strings by dynamically adding the strings to ArrayList and using that in list view. I have declared this as below
public static List<String> myList = new ArrayList<String>();
this helps me in retaining the values of list even after exiting app, but i cant be able to retain it after i force close the app or cell boots off and on. Is there any way to store this list as we do in shared preference for strings and int?
Couple of methods.
1) Store the entire list as a Single String (delimiter separated) and split it when you read it back (depends on what kind of strings, because if you have delimiters inside the string, you’re screwed, although you could use some kinda encoding (Base64))
2) Store them as separate variables “Key0” is the first element, “Key1” is the second…etc You get the idea…Remember to flush the Keys each time you save though.
3) Don’t use Shared Preference, instead use a private file and write the entire ArrayList Object (It’s serializable.) using a
ObjectOutputStreamCheers.