Android: getSharedPreferences for session -
okay, check source code:
public void checksession() { sharedpreferences session = getsharedpreferences(prefs_name, 1); string getsession = session.getstring("session", null); toast.maketext(this, getsession, toast.length_short).show(); if(getsession.length() > 30) { intent menu = new intent(this, menu.class); startactivity(menu); finish(); } else { } }
the problem "first time users" crush.
when disable function, run app , login code creates session. after when logout, , restart app - there's no problem. ideas?
first time app runs , don't have value stored in sharedpreference "session" return null default value. getsession().length result in nullpointerexception.
you should instead:
string getsession = session.getstring("session", "");
Comments
Post a Comment