SharedPreferences in fragment?

Viewed 44

i want have to fragment and in database i set a column for loginStatus by default its signout but when he sign in change to sign in and save in app the user sign in ... how can i do this with sharedpreferences to keep sign in user in application?

2 Answers

You don't need to use sharedPreferences, you can update the column from signout to signin directly in you database.

use this code

SharedPreferences prefs;
prefs= PreferenceManager.getDefaultSharedPreferences(getActivity());
SharedPreferences.Editor editor = prefs.edit();
editor.putString("isSignIn", "Yes");
editor.commit();
Related