Hello all along i was looking for a way to save and retrieve an Arraylist with custom object into android Sharedpreferences. Lucky enough i got a way to do it using this Answer
public void saveArray(ArrayList<CartItem> sKey)
{
SharedPreferences sp = PreferenceManager
.getDefaultSharedPreferences(this.getApplicationContext());
SharedPreferences.Editor mEdit1 = sp.edit();
Gson gson = new Gson();
String json = gson.toJson(sKey);
mEdit1.putString("itemx", json);
mEdit1.commit();
}
public ArrayList<CartItem> readArray(){
SharedPreferences appSharedPrefs = PreferenceManager
.getDefaultSharedPreferences(this.getApplicationContext());
String json = appSharedPrefs.getString("itemx", "");
Gson gson = new Gson();
Type type = new TypeToken<ArrayList<CartItem>>(){}.getType();
ArrayList<CartItem> List = gson.fromJson(json, type);
return List;
}
Now here comes a part where i want to only delete one of the object in the arraylist, how can i do it?