How to change values in the shared preference

sean picture sean · Jan 28, 2011 · Viewed 26.5k times · Source

I've created an application which uses a shared preference in order for the user to login. The password of the user is saved in the preference. My problem is, how can I change the password in the preference if the user wants to change his/her password?

Answer

Cristian picture Cristian · Jan 28, 2011
SharedPreferences prefs = ... // you already know how to use prefs and have one of this objects
Editor editor = prefs.edit();
editor.putString("password", "new value");
editor.apply();