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 int getHeartbeatIntervalMillisForWifi(Context context) {
    return Integer.parseInt(PreferenceManager.getDefaultSharedPreferences(context)
            .getString("pref_gcm_heartbeat_interval_wifi", "5")) * 60000;
}

From source file:Main.java

public static Long getLongSPR(String key, Context context) {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    return preferences.getLong(key, Long.MAX_VALUE);
}

From source file:Main.java

public static void clearAllSharedPreferencesList(Context context) {
    SharedPreferences sPrefs = PreferenceManager.getDefaultSharedPreferences(context);
    SharedPreferences.Editor sEdit = sPrefs.edit();
    sEdit.clear();/*from w  ww  . j a va  2 s . c o  m*/
    sEdit.commit();
}

From source file:Main.java

public static int getHeartbeatIntervalMillisForMobile(Context context) {
    return Integer.parseInt(PreferenceManager.getDefaultSharedPreferences(context)
            .getString("pref_gcm_heartbeat_interval_mobile", "5")) * 60000;
}

From source file:Main.java

public static SharedPreferences getPrefs() {
    return PreferenceManager.getDefaultSharedPreferences(getContext());
}

From source file:Main.java

public static boolean getCombineBlockAgendas(Context context) {
    try {//from w  ww  .j  a v  a2s.com
        return PreferenceManager.getDefaultSharedPreferences(context).getBoolean("combineBlockAgendas", false);
    } catch (UnsupportedOperationException e) {
        return false;
    }
}

From source file:Main.java

public static String getData(Context context, String key) {
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
    return sharedPreferences.getString(key, "");
}

From source file:Main.java

public static String getStringFromPreference(Context context, String key) {
    SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
    return pref.getString(key, null);
}

From source file:Main.java

public static void setRoleToPref(Context mContext, int role) {
    SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(mContext).edit();
    editor.putInt("userRole", role);
    editor.apply();//from   w  w w  .  j  a  v a 2 s  .  c  o  m
}

From source file:Main.java

public static int getLevelOfRecursion(Context context) {
    return Integer.parseInt(
            PreferenceManager.getDefaultSharedPreferences(context).getString("viewRecursionMax", "0"));
}