Android - Cannot Access SharedPreferences Booleans - Nothing Appears In LogCat -


i've implemented instance of shared preferences using following method:

startpoint:

sharedpreferences prefs=getpreferences(context.mode_private);         sharedpreferences.editor editor=prefs.edit();         editor.putboolean("name",true);         editor.putboolean("cap",true);         editor.putboolean("code",true);         editor.putboolean("time",true);         editor.putboolean("ssid",true);         editor.commit(); 

endpoint:

sharedpreferences prefs = getsharedpreferences(ndef_pref, context.mode_private);              boolean name = prefs.getboolean("name", true);              boolean cap= prefs.getboolean("cap", true);             boolean code = prefs.getboolean("code", true);             boolean time = prefs.getboolean("time", true);             boolean ssid = prefs.getboolean("ssid", true); 

test method:

boolean istrue;                 istrue = null; // valid                 istrue = true; // valid                 istrue = false; // valid                 if (istrue == null) {                     log.d(tag, "working boolean!!!"); 

and

boolean istrue;             istrue = null; // valid             istrue = true; // valid             istrue = false; // valid             if (istrue != null) {                 log.d(tag, "non working boolean!!!"); 

result:

nothing appears in logcat using either method

question:

did implement correctly? if - why can't null check new shared preferences?

i have try below code , guess show in logcat "val if null"

public void oncreate(bundle savedinstancestate)  { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main);  sharedpreferences pref = getpreferences(context.mode_private); sharedpreferences.editor editor = pref.edit(); editor.putboolean("name", true);  sharedpreferences prefs = getsharedpreferences("prefs",0); // boolean val=prefs.getboolean("name1", true); boolean  val=null; //log.e("vaaa00", ""+val.tostring()); if(val!= null)    log.e("val if ", ""+val); else    log.e("val else", ""+val);         } 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -