I get JSON from a service, i save it in preference, and when user needs to check session or fetch data, he uses this method getProfileObject(), and it returns ArrayList in return.
This is my method that is responsible to get Json from preference and generate ArrayList by using Gson
SharedPreferences sharedPreferences=ApplicationContext.getAppContext().getSharedPreferences(USER_DATA_PREFERENCE, ApplicationContext.MODE_PRIVATE);
profileObject= sharedPreferences.getString(PROFILE_OBJECT, "");
if(!profileObject.isEmpty()) {
GsonBuilder gsonBuilder = new GsonBuilder();
Gson gson = gsonBuilder.create();
this.dataList = Arrays.asList(gson.fromJson(profileObject, Profile.class));
return dataList;
}
Now i want to avoid this Gson step each time, I want to store arrayList is shared preference, Is it possible to store java array list in shared preference.