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

private static void setKeyboardPortraitHeight(Context context, int height) {
    PreferenceManager.getDefaultSharedPreferences(context).edit().putInt("keyboard_height_portrait", height)
            .apply();//from  ww w  . ja v a2 s  .  c o m
}

From source file:Main.java

public static boolean hasBind(Context context) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    String flag = sp.getString("bind_flag", "");
    if ("ok".equalsIgnoreCase(flag)) {
        return true;
    }//w  w w .  j  a  va 2  s.  c o m
    return false;
}

From source file:Main.java

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

From source file:Main.java

private static void setKeyboardLandscapeHeight(Context context, int height) {
    PreferenceManager.getDefaultSharedPreferences(context).edit().putInt("keyboard_height_landscape", height)
            .apply();//from   www  . j av a 2s.  com
}

From source file:Main.java

public static void delObject(Context context, String key) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    SharedPreferences.Editor editor = sp.edit();
    editor.remove(key);/*from  www .  j av  a 2s.  c o m*/
    editor.commit();
}

From source file:Main.java

public static int getRoleFromPref(Context mContext) {
    SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(mContext);
    int role = pref.getInt("userRole", -2);
    return role;//from  www .  jav  a2s . c  o m
}

From source file:Main.java

public static void init(Context context) {
    prefs = PreferenceManager.getDefaultSharedPreferences(context);
}

From source file:Main.java

public static String getPreferredSortSetting(Context context) {
    SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
    return pref.getString("sort", "popular");
}

From source file:Main.java

public static SharedPreferences getDefaultSharedPreferences(Context context) {
    return PreferenceManager.getDefaultSharedPreferences(context);
}

From source file:Main.java

public static boolean isAutoSyncChecked(Context context) {
    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
    return settings.getBoolean("autoSync_pref", false);
}