I'm trying to save an int I get from an EditText, and as people said it will be best with SharedPreference, I listened, but everytime i'm trying to save/load, the program crashes! any ideas?
public static final String MY_PREFS_NAME = "MyPrefsFile";
String getsturdvalue;
int sturd;
EditText sturdadapter;
int sturdadaptercount;
public void onSave(View view) {
SharedPreferences.Editor editor = (SharedPreferences.Editor) getSharedPreferences(MY_PREFS_NAME, MODE_PRIVATE);
editor.putInt(getstrengthvalue, strnth);
editor.apply();
}
public void onLoad(View view) {
SharedPreferences prefs = getSharedPreferences(MY_PREFS_NAME, MODE_PRIVATE);
String restoredText= prefs.getString("text", null);
if (restoredText != null) {
int insertvalue = prefs.getInt("insertvalue", strnth);
int adapter = prefs.getInt("adapter", strengthadaptercount);
}
strengthadapter.setText(prefs.getInt("" ,strengthadaptercount));
}