Example usage for android.preference PreferenceManager getDefaultSharedPreferences

List of usage examples for android.preference PreferenceManager getDefaultSharedPreferences

Introduction

In this page you can find the example usage for android.preference PreferenceManager getDefaultSharedPreferences.

Prototype

public static SharedPreferences getDefaultSharedPreferences(Context context) 

Source Link

Document

Gets a SharedPreferences instance that points to the default file that is used by the preference framework in the given context.

Usage

From source file:Main.java

public static void storeLoginStatus(Context context, String loginStatus) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    SharedPreferences.Editor editor = prefs.edit();
    editor.putString(LOGIN, loginStatus);
    editor.apply();/*from  ww  w. j a v a2 s . c  om*/
}

From source file:Main.java

public static void setUserGender(final Context context, final String gender) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    sp.edit().putString(PREF_GENDER, gender).commit();
}

From source file:Main.java

public static void setCipher(Context context, String aes) {
    if (null == context) {
        return;/* www.  j  a va 2s  . co  m*/
    }
    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
    SharedPreferences.Editor editor = settings.edit();
    editor.putString("cipher", aes);
    editor.commit();
}

From source file:Main.java

public static void putFloat(final Context context, final String key, final float value) {
    if (context != null) {
        final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
        final SharedPreferences.Editor editor = settings.edit();
        editor.putFloat(key, value).apply();
    }//w w w. j av a2 s . c  om
}

From source file:Main.java

public static int getNumTickers(Context context) {
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
    return sharedPreferences.getInt(PREF_NUM_TICKERS, 0);
}

From source file:Main.java

public static Set<String> getLoggedInUsers(Context context) {
    return PreferenceManager.getDefaultSharedPreferences(context).getStringSet(LOGGED_IN_USER_PREFERENCE_KEY,
            new HashSet<>());
}

From source file:Main.java

public static void setPrefMenlofont(final Context context, boolean b) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    sp.edit().putBoolean(PREF_MENLO_FONT, b).commit();
}

From source file:Main.java

public static void storeIntSharePref(Context context, String key, int value) {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    SharedPreferences.Editor editor = preferences.edit();
    editor.putInt(key, value);/*ww  w. j a  va  2 s.c  o m*/
    editor.apply();
}

From source file:Main.java

public static void setPreference(Context context, String preference, String value) {
    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
    SharedPreferences.Editor editor = settings.edit();
    editor.putString(preference, value);
    editor.apply();/* w w w.  ja v  a2  s . c  o m*/
}

From source file:Main.java

public static void setFullName(final Context context, final String fullName) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    sp.edit().putString(PREF_FULLNAME, fullName).apply();
}