I\'m building an app which searches the web using search engine. I have one edittext in my app from which user will search the web. I want to save the search keywords just l
Convert your array or object to Json with Gson library and store your data as String in json format.
Save;
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
Editor editor = sharedPrefs.edit();
Gson gson = new Gson();
String json = gson.toJson(arrayList);
editor.putString(TAG, json);
editor.commit();
Read;
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
Gson gson = new Gson();
String json = sharedPrefs.getString(TAG, null);
Type type = new TypeToken>() {}.getType();
ArrayList arrayList = gson.fromJson(json, type);
Original answer: Storing Array List Object in SharedPreferences