I thought what you want - at some point you want to show the saved value (comes from general preference) in the spinner as the selected item. For this
install the spinner adapter with all the defaults that include your saved value. Now you want to show the saved value as the selected one. Suppose you have 6 elements in an adapter
String savedValue=PreferenceManager .getDefaultSharedPreferences(context) .getString("savedValue",""); for(int i=0;i<6;i++) if(savedValue.equals(spinner.getItemAtPosition(i).toString())){ spinner.setSelection(i); break; }
To keep the counter value under common preferences do this
SharedPreferences prefs; prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor prefEditor = prefs.edit(); prefEditor.putString("savedValue",spinner.getSelectedItem().toString()); prefEditor.commit();
source share