How can I store an ArrayList<HashMap<String, String>> in SharedPreferences?
I wish to store an ArrayList which contains Hashmap inside SharedPreferences. How can I do this? You can convert your collection into a json and store it in shared preference. Whenever you need to get the data, just get the string and convert the JSON back into your collection. //converting the collection into a JSON JSONArray result= new JSONArray(collection); SharedPreferences pref = getApplicationContext().getSharedPreferences(PREF_NAME, 0); //Storing the string in pref file SharedPreferences.Editor prefEditor = pref.edit(); prefEditor.putString(KEY, result.toString()); prefEditor.commit();