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 saveCache(Context context, String key, String result) {
    SharedPreferences sp = context.getSharedPreferences("cacheUtils", Context.MODE_PRIVATE);
    sp.edit().putString(key, result).apply();
}

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 String getString(Context context, String key) {

    SharedPreferences sharedPreferences = context.getSharedPreferences("atqiye", Context.MODE_PRIVATE);
    return sharedPreferences.getString(key, "");
}

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

static String getSaveLocation(Context context, String saveName) {
    SharedPreferences prefs = context.getSharedPreferences("com.ihelp101.xinsta", Context.MODE_PRIVATE);

    return prefs.getString(saveName, "Instagram").replace("file://", "").replaceAll("%20", " ");
}

From source file:Main.java

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

From source file:Main.java

public static void writeCameraId(Context context, String value) {
    SharedPreferences preferences = context.getSharedPreferences("CameraConfig", Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = preferences.edit();
    editor.putString("camera", value);
    editor.commit();//  ww  w .  j  av a  2 s  .  c o m
}

From source file:Main.java

public static String getString(Context context, String key, String defaultValue) {
    return context.getSharedPreferences(SP_NAME, Context.MODE_PRIVATE).getString(key, defaultValue);
}