android - Why sharedpreference value not getting in when retrieving? -


i aaded 3 shared preferences below code. , able retrieve onl n shared preference value.

sharedpreferences preferences = preferencemanager.getdefaultsharedpreferences(getapplicationcontext());             sharedpreferences.editor editor = preferences.edit();             editor.putboolean("loggedin",true);             editor.putstring("userid",userid);             editor.putstring("pwd",password);             editor.apply();             editor.commit(); 

i used following code retrieving activity. able retrieve boolean value. other values not there. getting default value string values. please me.

   sharedpreferences preferences = preferencemanager.getdefaultsharedpreferences(getapplicationcontext());                  boolean loggedin=preferences.getboolean("loggedin", false);                 string userid=preferences.getstring("userid", "0");                 string pwd=preferences.getstring("pwd", "0"); 

check first value u store in preferences stored or not using code

boolean loggedin=preferences.getboolean("loggedin", false);  string userid=preferences.getstring("userid", null);  string pwd=preferences.getstring("pwd", null);   if(userid==null || pwd==null) { //data not therer } else { //do data } 

and let me know if error occured..


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -