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 int getInt(Context context, String title) {
    SharedPreferences sp = context.getSharedPreferences(FILENAME, Context.MODE_PRIVATE);
    return sp.getInt(title, 0);
}

From source file:Main.java

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

    return sp.getBoolean(key, false);
}

From source file:Main.java

public static int getMaxIndex(Context mContext) {
    SharedPreferences settings = mContext.getSharedPreferences("clock", Context.MODE_PRIVATE);
    return settings.getInt(MAX_INDEX, 0);
}

From source file:Main.java

public static String getString(String fileName, Context context, String keyId, String defaultValue) {
    SharedPreferences sharedPreferences = context.getSharedPreferences(fileName, Context.MODE_PRIVATE);
    return sharedPreferences.getString(keyId, defaultValue);
}

From source file:Main.java

static public SharedPreferences getSharedPref(Context context) {
    return context.getSharedPreferences(ZPREFERENCES, Context.MODE_PRIVATE);
}

From source file:Main.java

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

From source file:Main.java

public static void appUsageNumber(Context context) {
    SharedPreferences settings = context.getSharedPreferences("Settings", Context.MODE_PRIVATE);
    Integer number = settings.getInt("usage_num", 0);

    settings.edit().putInt("usage_num", number + 1).commit();
}

From source file:Main.java

public static String getFaceUri(String faceId, Context context) {
    SharedPreferences faceIdUriMap = context.getSharedPreferences("FaceIdUriMap", Context.MODE_PRIVATE);
    return faceIdUriMap.getString(faceId, "");
}

From source file:Main.java

public static Long getLong(Context context, String title) {
    SharedPreferences sp = context.getSharedPreferences(FILENAME, Context.MODE_PRIVATE);
    return sp.getLong(title, 0);
}

From source file:Main.java

public static void delString(Context context, String key) {
    if (sp == null) {
        sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
    }/*from w  w w . ja  va  2  s  . c om*/
    sp.edit().remove(key).apply();
}