User not being saved, SharedPreferences
- by Lars
Hi i have a inlogscreen (inlogdialog.xml), which includes 2 EditText (username, passwd) and i have a CheckBox (saveuser) with which the user can decide weather to save the username or not.
On the mainform (main.xml) i have a listner for these 3 values:
private class OnReadyListener implements MyCustomForm.ReadyListener {
public void ready(String user, String pass, boolean save) {
username = user;
password = pass;
}
}
Now i first want to save the username through SharedPreferences but it doesn`t get saved, can someone help me please?
If i check with system.out.println, the username is present in String username.
SharedPreferenes code in main.xml:
public static final String USERNM = "";
private SharedPreferences mPrefs;
.......
@Override
protected void onPause() {
Editor e = mPrefs.edit();
e.putString(USERNM, username); <----
e.commit();
Toast.makeText(this, "Items saved.", Toast.LENGTH_SHORT).show();
super.onPause();
}