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 SharedPreferences getSharedPreferences(Context context, String name) {
    return context.getSharedPreferences(name, Context.MODE_PRIVATE);
}

From source file:Main.java

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

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 boolean getModeResult(Context context) {

    SharedPreferences sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);

    if (sp.getBoolean("nightState", false)) {
        return true;
    } else {/*from  w w w. j a  v  a 2 s.co m*/
        return false;
    }
}

From source file:Main.java

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

From source file:Main.java

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

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 String getString(Context context, String key) {
    SharedPreferences sp = context.getSharedPreferences("configdata", Context.MODE_PRIVATE);
    String result = sp.getString(key, null);
    return result;
}

From source file:Main.java

public static String getPhoneNumber(Context context) {
    SharedPreferences prefs = context.getSharedPreferences("LOGIN_preferences", Context.MODE_PRIVATE);
    return prefs.getString("PHONE", "");
}

From source file:Main.java

public static String getUserMail(Context mContext) {
    SharedPreferences sharedPref = mContext.getSharedPreferences("IdentifyInfos", Context.MODE_PRIVATE);
    return sharedPref.getString("user_mail", "");
}