Search code examples
androidsqlandroid-studiosharedpreferences

SharedPreferences in fragment?


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?


Solution

  • use this code

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