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 saveDate(Context context) {
    SharedPreferences sp = context.getSharedPreferences("upushlog_time", Context.MODE_PRIVATE);
    if (0 == sp.getLong("time", 0)) {
        sp.edit().putLong("time", System.currentTimeMillis()).commit();

    }//w  ww. j  a v  a2  s.  co m

}

From source file:Main.java

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

From source file:Main.java

private static boolean isAlreadyGetPhoneResolution(Activity activity) {
    SharedPreferences config = activity.getSharedPreferences("config", Context.MODE_PRIVATE);
    return config.getBoolean("isAlreadyGetPhoneResolution", false);
}

From source file:Main.java

public static void unbind(Context context) {
    SharedPreferences sp = context.getSharedPreferences("pre_tuisong", Context.MODE_PRIVATE);
    sp.edit().putBoolean(BIND__FLAG, false).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();//from  w ww .j a  va2  s . com
    editor.commit();
}

From source file:Main.java

public static SharedPreferences.Editor remove(Context context, String fileName, String name) {
    SharedPreferences sharedPreferences = context.getSharedPreferences(fileName, Context.MODE_PRIVATE);
    return sharedPreferences.edit().remove(name);
}

From source file:Main.java

public static void savePushItemId(final Context mContext, final String itemId) {
    SharedPreferences preferences = mContext.getSharedPreferences("com.livechat.chat", Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = preferences.edit();
    editor.putString("itemId", itemId);
    editor.commit();/*  ww w. ja  v  a 2 s  .c om*/
}

From source file:Main.java

public static int getInt(Context context, String key) {
    if (sp == null) {
        sp = context.getSharedPreferences("gjw", Context.MODE_PRIVATE);
    }//w w w .jav  a2s .c  o  m
    return sp.getInt(key, 0);
}

From source file:Main.java

public static void setStoredVar(Activity activity, String key, String val) {
    SharedPreferences settings = activity.getSharedPreferences(key, Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = settings.edit();
    editor.putString(key, val);
    editor.commit();/*from w  w  w  .j  a  v a2 s.c  o m*/
}

From source file:Main.java

public static void clearCampaignCache(Context context) {
    String USER_FILE = "campaign";
    SharedPreferences.Editor editor = context.getSharedPreferences(USER_FILE, Context.MODE_PRIVATE).edit();
    editor.clear();/*from www. jav a2s  . c  o  m*/
    editor.putBoolean("is_cached", false);
    editor.apply();
}