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
Post a Comment