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 contains(final Context context, final String key) {
    if (context != null) {
        final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
        return settings.contains(key);
    }//from w  w w  . ja  v a 2 s  .c  o m
    return false;
}

From source file:Main.java

public static boolean isInitDb(Context context) {
    final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
    return settings.getBoolean(EXTRA_ISINITDB, false);
}

From source file:Main.java

public static boolean isFirstLaunch(Context context) {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    return preferences.getBoolean(FIRST_TIME, true);

}

From source file:Main.java

public static int fetchIntSharePref(Context context, String key) {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    return preferences.getInt(key, 0);
}

From source file:Main.java

/**
 * Gets the stored account name//from w  w w .  j  a v a  2  s . c  o m
 */
public static String getAccountName(Context applicationContext) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(applicationContext);
    return prefs.getString("GDOCS_ACCOUNT_NAME", "");
}

From source file:Main.java

public static void storeAdmin(Context context, String isAdmin) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    SharedPreferences.Editor editor = prefs.edit();
    editor.putString(ADMIN, isAdmin);/* w  w  w .j ava  2s.c  o m*/
    editor.apply();
}

From source file:Main.java

public static void storePinCode(Context context, String code) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    SharedPreferences.Editor editor = prefs.edit();
    editor.putString(PINCODE, code);//from w  ww.  jav  a2s  .  c  o m
    editor.apply();
}

From source file:Main.java

public static Boolean checkSharedPref(Context context, String key) {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    return preferences.contains(key);
}

From source file:Main.java

public static void setUserId(final Context context, final String userId) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    sp.edit().putString(PREF_ID, userId).commit();
}

From source file:Main.java

public static long fetchLongSharePref(Context context, String key) {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    SharedPreferences.Editor prefsEditor = preferences.edit();
    return preferences.getLong(key, -1);
}