I'm trying to save a string in preference by adding it to the editor when a user press a button. Then i'm trying to retreieve the strings from the preference and turn it into an arrayList.
in onCreate
this.context = getApplicationContext();
SharedPreferences prefs = getSharedPreferences(SHARED_PREFS_FILE, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
int size = updatableList.size();
editor.putInt("list_size", size);
for (int i = 0; i < size; i++) {
((SharedPreferences) editor).getString("list_"+i, updatableList.get(i));
}
editor.commit();
Later in the application
updatableList.add(picturePath);
i=i++;
//saving path to preference********
SharedPreferences prefs = getSharedPreferences(SHARED_PREFS_FILE, Context.MODE_PRIVATE);
((Editor) editor).putString("list_"+i, picturePath);
editor.commit();
It says the prefs later in the application is unused which i think is odd because i thought it told it to putString. The application crashes when it gets to there. Why does my prefs later in the application get used?