Friday, 15 January 2010

sharedpreferences - I want to implement one time registration screen in android using shared preferences but i'm not able to get the previous shared preferences -



sharedpreferences - I want to implement one time registration screen in android using shared preferences but i'm not able to get the previous shared preferences -

i want retrieve stored shared preferences. have implemented sec activity. want user come in info 1 time

@override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); sp = this.getsharedpreferences(text_value_key, context.mode_private); completed = sp.getboolean(text_value_key, false); if (completed == true) { intent intent = new intent(); intent.setclass(this, welcome.class); toast.maketext(getbasecontext(), "user registered", toast.length_short).show(); startactivity(intent); finish(); } number = (edittext) findviewbyid(r.id.user_number); btn= (button) findviewbyid(r.id.register_button); }

it seems not saving , retrieve shared preferences right. save preference seek this, simpler.

sharedpreferences sp = preferencemanager.getdefaultsharedpreferences( this); editor edit = sp.edit(); edit.putboolean("completed",x); //you can set more objects edit.commit();

to shared preferences,

sharedpreferences sp = preferencemanager.getdefaultsharedpreferences.(this); boolean completed = sp.getboolean("completed",false);

also putting string , trying boolean.

android sharedpreferences

No comments:

Post a Comment