Hello!
I want to save text from 2 edittexts(et1,et2) and selection from 3 spinners(spinnerm,spinner and spinner2) onPause and setting them back onResume. Text from edittexts is saved correctly, only spinner selection don't work as desired. My code:
public void onResume(){
super.onResume();
Log.d("REZUM","notr smo");
SharedPreferences seti = getSharedPreferences( "pavzica", MODE_PRIVATE);
spinnerm.setSelection(seti.getInt("m", 0));
spinner.setSelection(seti.getInt("k", 0));
spinner2.setSelection(seti.getInt("p", 0));
et1.setText(seti.getString("zade", ""));
et2.setText(seti.getString("Vseb", ""));
}
public void onPause() {
shraniPolja();
super.onPause();
}
public void shraniPolja() {
SharedPreferences seti = getSharedPreferences( "pavzica", MODE_PRIVATE);
SharedPreferences.Editor edito = seti.edit();
edito.putString("zade", et1.getText().toString());
edito.putString("Vseb", et2.getText().toString());
edito.putInt("m", spinnerm.getSelectedItemPosition());
edito.putInt("k", spinner.getSelectedItemPosition());
edito.putInt("p", spinner2.getSelectedItemPosition());
edito.putBoolean("b", true);
edito.commit();
}
What am i doing wrong?