Android issue with boolean on shared preferences -


android issue boolean on shared preferences

sharedpreferences spref = preferencemanager.getdefaultsharedpreferences(this); boolean isslide=spref.getboolean("slide_show",false);     //in isslide getting right value if statement not working  if(isslide==true){ //if true page slide works in false } 

i tried in link issue boolean on shared preferences answer not clear

settings code:

  <preferencecategory android:title="slide show" >        <checkboxpreference android:title="slide show" android:key="slide_show" />     </preferencecategory>  

you may want check if sharedpreference variables active. example on how set sharedpreference.

to write sharedpreference:

sharedpreferences prefs = getsharedpreferences("mypref", 0);  sharedpreferences.editor editor = prefs.edit(); editor.putboolean("mybool", true); editor.commit(); 

to read sharedpreference:

sharedpreferences prefs = getsharedpreferences("mypref", 0);  if (prefs.getboolean("mybool", false)) { //mybool true; } 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -