android - Saving user details using SharedPreferences -



android - Saving user details using SharedPreferences -

hi want application remember login details of user 1 time user has logged in until user press "log out" button. i'm using style

private checkbox mchecksavepassword; mchecksavepassword.setchecked(preferences.getboolean("prefsavepassword", false)); sharedpreferences.editor preferenceseditor = preferences.edit(); preferenceseditor.putstring("prefusername", username); if(mchecksavepassword.ischecked()) { preferenceseditor.putstring("prefpassword", password); } preferenceseditor.putboolean("prefsavepassword", mchecksavepassword.ischecked()); preferenceseditor.commit();

but doesnt works

try way,hope help solve problem.

how set :

sharedpreferences sharedpreferences = getsharedpreferences(getstring(r.string.app_name), mode_private); sharedpreferences.editor editor = sharedpreferences.edit(); editor.putboolean("prefusername", username); editor.putboolean("prefpassword", mchecksavepassword.ischecked()?password:""); editor.commit();

how :

sharedpreferences sharedpreferences = getsharedpreferences("yoursharepreferencename", mode_private); mchecksavepassword.setchecked(sharedpreferences.getstring("prefpassword","").trim().length()>0?true:false);

android android-studio

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -