I am an iOS developer who is trying to learn Android and I would like to make sure that I am following best practices.
I have custom objects that need to be accessible by 1 -> m activities and they need to be saved when the application closes. Currently I am using SharedPreferences, code below, to save them but I am not sure if it is the best route. Should I be using a singleton? Is there a better way?
SharedPreferences mPrefs = getPreferences(MODE_PRIVATE);
Editor prefsEditor = mPrefs.edit();
Gson gson = new Gson();
String json = gson.toJson(userProfile);
prefsEditor.putString("UserProfile", json);
prefsEditor.commit();
gson = new Gson();
json = mPrefs.getString("UserProfile", "");
UserProfileObject outObject = gson.fromJson(json, UserProfileObject.class);