I am writing an app to save password with a log in interface. The user can change the log in password. I use the following code to save the password, so that the password will not reset when the app relaunch.
@Override
public void onSaveInstanceState(Bundle savedInstanceState){
savedInstanceState.putString("pwd", currentPwd);
super.onSaveInstanceState(savedInstanceState);
}
@Override
public void onRestoreInstanceState(Bundle savedInstanceState){
currentPwd = savedInstanceState.getString("pwd");
}
But I found that it can only save the password for a while. When I wait it for a long time, about 1 hours, without reboot the mobile, it will reset my password.
How to save the password so that it will not reset?
you have to save the data using sharedpreferences:
then you can retreive it: