I have an ArrayList
with custom objects. Each custom object contains a variety of strings and numbers. I need the array to stick around even if the user leaves
Saving Array
in SharedPreferences
:
public static boolean saveArray()
{
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor mEdit1 = sp.edit();
/* sKey is an array */
mEdit1.putInt("Status_size", sKey.size());
for(int i=0;i
Loading Array
Data from SharedPreferences
public static void loadArray(Context mContext)
{
SharedPreferences mSharedPreference1 = PreferenceManager.getDefaultSharedPreferences(mContext);
sKey.clear();
int size = mSharedPreference1.getInt("Status_size", 0);
for(int i=0;i