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 boolean saveSetting(Context c, String key, String value) {
    SharedPreferences shared = PreferenceManager.getDefaultSharedPreferences(c);

    Editor e = shared.edit();/*from ww  w.ja v  a 2s.c o m*/

    e.putString(key, value);
    return e.commit();
}

From source file:Main.java

public static String fetchObjectSharePref(Context context, String key) {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    SharedPreferences.Editor prefsEditor = preferences.edit();
    return preferences.getString(key, "");
}

From source file:Main.java

public static void deleteSharedPreferencesKey(Context context, String key) {
    SharedPreferences mySPrefs = PreferenceManager.getDefaultSharedPreferences(context);
    SharedPreferences.Editor editor = mySPrefs.edit();
    editor.remove(key);//from w  w  w .j a va  2  s.  c  om
    editor.apply();
}

From source file:Main.java

public static void setUserEmail(final Context context, final String email) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    sp.edit().putString(PREF_EMAIL, email).commit();
}

From source file:Main.java

public static void setUserEmail(final Context context, final String email) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    sp.edit().putString(PREF_EMAIL, email).apply();
}

From source file:Main.java

public static void setUrl(Context context, String url) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    prefs.edit().putString(PREFERENCE_DSU_URL, url).commit();
}

From source file:Main.java

public static Boolean fetchBoolianSharePref(Context context, String key) {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    SharedPreferences.Editor prefsEditor = preferences.edit();
    return preferences.getBoolean(key, false);
}

From source file:Main.java

public static void setLoginState(Context context, boolean isLogin) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    SharedPreferences.Editor editor = prefs.edit();
    editor.putBoolean(STATE_LOGIN, isLogin);
    editor.commit();/* w w  w.  j  av a  2  s  . c  om*/
}

From source file:Main.java

public static void setIsInitDb(Context context, boolean b) {
    final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
    settings.edit().putBoolean(EXTRA_ISINITDB, b).commit();
}

From source file:Main.java

public static boolean isIncludeAdult(final Context context) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    return sp.getBoolean(PREF_INCLUDE_ADULT, false);
}