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 clear(Context context) {
    SharedPreferences sp = context.getSharedPreferences(FILENAME, Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = sp.edit();
    editor.clear();/*from   w w  w.ja va  2  s  .  c o  m*/
    editor.apply();
}

From source file:Main.java

public static String getStr(Context mContext, String name, String key, String defaultValue) {
    SharedPreferences sharedPreferences = mContext.getSharedPreferences(name, Context.MODE_PRIVATE);
    return sharedPreferences.getString(key, defaultValue);
}

From source file:Main.java

public static boolean getIsOpen(final Context mContext) {
    SharedPreferences preferences = mContext.getSharedPreferences("com.livechat.chat_open",
            Context.MODE_PRIVATE);
    return preferences.getBoolean("isOpen", false);
}

From source file:Main.java

public static boolean checkLogin(Context context) {
    SharedPreferences userPreferences = context.getSharedPreferences("umeng_general_config",
            Context.MODE_PRIVATE);
    String string = userPreferences.getString("jdycode", "");
    if (string.length() > 10) {
        return true;
    }// w w  w .java2s. com
    return false;
}

From source file:Main.java

public static void bind(Context context) {
    SharedPreferences sp = context.getSharedPreferences("pre_tuisong", Context.MODE_PRIVATE);
    sp.edit().putBoolean(BIND__FLAG, true).commit();
}

From source file:Main.java

public static void clear(Context context) {
    SharedPreferences sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = sp.edit();
    editor.clear().commit();//from w w w.  jav  a2 s .  c om
}

From source file:Main.java

public static void resetPref(Context context) {
    SharedPreferences pref = context.getSharedPreferences("TVGuide", Context.MODE_PRIVATE);
    Editor editor = pref.edit();/*from ww w .  j a v a  2s.com*/
    editor.clear();
    editor.apply();
}

From source file:Main.java

public static int getDataFromShared(String sharedKey, String key, Context context) {

    SharedPreferences sharedPreferences = context.getSharedPreferences(sharedKey, Context.MODE_PRIVATE);

    return sharedPreferences.getInt(key, 0);
}

From source file:Main.java

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

}

From source file:Main.java

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