Android: Login and Logout in all the activities -
am beginner android, have 1 clarification in login & logout... username , password through json....so no problem that....
now, there 3 activities in app.. activities has "login " function, if login in of 3 activities, should logged in activities.
and same way , if logout in of 3 activities, should logged out activities.
thanks.
you can use shared preference this. store boolean value islogin true if login , make false when logout according display string
some sample code if not know preference
public string getstringpreference(string key) { return settings.getstring(key, null); } public void setstringpreference(string key, string value) { settings.edit().putstring(key, value).commit(); } in activity's or application's oncreate, call this:
settings = getapplicationcontext().getsharedpreferences(prefs_file, context.mode_private);
Comments
Post a Comment