Example usage for android.content Context MODE_PRIVATE

List of usage examples for android.content Context MODE_PRIVATE

Introduction

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

Prototype

int MODE_PRIVATE

To view the source code for android.content Context MODE_PRIVATE.

Click Source Link

Document

File creation mode: the default mode, where the created file can only be accessed by the calling application (or all applications sharing the same user ID).

Usage

From source file:Main.java

public static void putBoolean(Context context, String key, boolean value) {
    SharedPreferences sp = context.getSharedPreferences("tron", Context.MODE_PRIVATE);
    sp.edit().putBoolean(key, value).commit();
}

From source file:Main.java

public static void putBoolean(Context context, String key, boolean value) {
    SharedPreferences sp = context.getSharedPreferences("fq", Context.MODE_PRIVATE);
    sp.edit().putBoolean(key, value).commit();
}

From source file:Main.java

public static boolean getBoolean(String key, boolean defValue, Context ctx) {
    SharedPreferences sp = ctx.getSharedPreferences("config", Context.MODE_PRIVATE);
    return sp.getBoolean(key, defValue);
}

From source file:Main.java

public static int getInt(String preName, Context context, String key) {
    SharedPreferences pre = context.getSharedPreferences(preName, Context.MODE_PRIVATE);
    return pre.getInt(key, -1);
}

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 void putString(Context context, String key, String value) {
    SharedPreferences sp = context.getSharedPreferences(key, Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = sp.edit();
    editor.putString(key, value);//  w w w  . j  a va 2  s. c  om
    editor.apply();
}

From source file:Main.java

public static void setIntToCache(Context context, String key, int value) {
    SharedPreferences sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
    sp.edit().putInt(key, value).commit();
}

From source file:Main.java

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

From source file:Main.java

public static void setPlaymode(Context context, String key, int value) {
    SharedPreferences sp = context.getSharedPreferences("atguigu", Context.MODE_PRIVATE);
    sp.edit().putInt(key, value).commit();
}

From source file:Main.java

public static void putMode(String txt, Context context, String key, int value) {
    SharedPreferences sp = context.getSharedPreferences(txt, Context.MODE_PRIVATE);
    sp.edit().putInt(key, value).commit();
}