java - Shared preferences user name -
i have app i'd able let user customize far setting user name, email address , picture navdrawer preference menu. i'm not 100% sure how though. i'm not sure how set listeners key preference screen. since these values have id's can replaced user preference put in?
any great.
since want these values persist through each use of app, use sharedpreferences save values. retrieve , set them in navdrawer adapter
sharedpreferences pref = preferencemanager.getdefaultsharedpreferences(youractivity.this); pref.edit().putstring("name", nameedittext.gettext().tostring()).commit();
to retrieve...
pref.getstring("name", defaultvalue);
any additional "putstring" using same key overwrite data.
hopefully answers question. if not can further. documentation too.
edit refer comments below.
actionbardrawertoggle mdrawertoggle = new actionbardrawertoggle(this,mdrawerlayout,r.drawable.ic_playlist, r.string.drawer_open, r.string.drawer_close) { @override public void ondrawerstatechanged(int newstate) { super.ondrawerstatechanged(newstate); } @override public void ondrawerclosed(view drawerview) { super.ondrawerclosed(drawerview); } @override public void ondraweropened(view drawerview) { super.ondraweropened(drawerview); } }
Comments
Post a Comment