Example usage for android.content Context getSharedPreferences

List of usage examples for android.content Context getSharedPreferences

Introduction

In this page you can find the example usage for android.content Context getSharedPreferences.

Prototype

public abstract SharedPreferences getSharedPreferences(File file, @PreferencesMode int mode);

Source Link

Document

Retrieve and hold the contents of the preferences file, returning a SharedPreferences through which you can retrieve and modify its values.

Usage

From source file:Main.java

public static Boolean getBoolean(Context mContext, String key) {
    SharedPreferences sp = mContext.getSharedPreferences("atguigu", Context.MODE_PRIVATE);
    return sp.getBoolean(key, false);
}

From source file:Main.java

public static int getDeskEffect(Context context) {
    SharedPreferences preferences = context.getSharedPreferences("DeskEffect", Context.MODE_PRIVATE);
    int effect = preferences.getInt("DeskEffectItem", 0);
    return effect;
}

From source file:Main.java

public static String readCache(Context context, String key) {
    SharedPreferences sp = context.getSharedPreferences("cacheUtils", Context.MODE_PRIVATE);
    return sp.getString(key, "");
}

From source file:Main.java

public static boolean getBooleanFromCache(Context context, String key) {
    SharedPreferences sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
    boolean isGuide = sp.getBoolean(key, false);
    return isGuide;
}

From source file:Main.java

public static String getFromPreferences(String key, Context mContext) {
    SharedPreferences preferences = mContext.getSharedPreferences(TRACKER_PREFERENCES, Context.MODE_PRIVATE);
    return preferences.getString(key, null);
}

From source file:Main.java

public static float getFloat(String preName, Context context, String key) {
    SharedPreferences pre = context.getSharedPreferences(preName, Context.MODE_PRIVATE);
    return pre.getFloat(key, 0.0f);
}

From source file:Main.java

public static String getString(String preName, Context context, String key) {
    SharedPreferences pre = context.getSharedPreferences(preName, Context.MODE_PRIVATE);
    return pre.getString(key, "");
}

From source file:Main.java

public static Boolean getBoolean(String preName, Context context, String key) {
    SharedPreferences pre = context.getSharedPreferences(preName, Context.MODE_PRIVATE);
    return pre.getBoolean(key, false);
}

From source file:Main.java

public static void saveSharedPreInteger(Context context, String key, int value) {
    settings = context.getSharedPreferences(XML_Settings, Context.MODE_PRIVATE);
    settings.edit().putInt(key, value).commit();
}

From source file:Main.java

public static boolean contains(Context context, String key) {
    SharedPreferences sp = context.getSharedPreferences(SP_NAME, Context.MODE_PRIVATE);
    return sp.contains(key);
}