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 setStringValue(Context context, String key, String value) {
    SharedPreferences sp = context.getSharedPreferences(CONFIG_NAME, Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = sp.edit();
    editor.putString(key, value).commit();
}

From source file:Main.java

public static int loadIntSavedPreferences(String key, Context ctx) {
    SharedPreferences sp = ctx.getSharedPreferences(sharedPrefsFile, Context.MODE_PRIVATE);
    int name = sp.getInt(key, -1);
    return name;//from  w w  w .j a v  a2s  . c om
}

From source file:Main.java

public static boolean putString(Context context, String key, String value) {
    SharedPreferences settings = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = settings.edit();
    editor.putString(key, value);/* ww w.j  av a 2s. c om*/
    return editor.commit();
}

From source file:Main.java

public static void setBooleanValue(Context context, String key, boolean value) {
    SharedPreferences sp = context.getSharedPreferences(CONFIG_NAME, Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = sp.edit();
    editor.putBoolean(key, value).commit();
}

From source file:Main.java

public static Boolean putString(String preName, Context context, String key, String value) {
    SharedPreferences pre = context.getSharedPreferences(preName, Context.MODE_PRIVATE);
    Editor editor = pre.edit();/*from  www  .  ja v a2  s  .  c o  m*/
    editor.putString(key, value);
    return editor.commit();
}

From source file:Main.java

public static void initCache(Context context) {
    sp = context.getApplicationContext().getSharedPreferences("config", Context.MODE_PRIVATE);
    isInitBoolean = true;/*w ww.ja  va2s . com*/
}

From source file:Main.java

public static String getString(Context mContext, String key) {
    String result = "";
    SharedPreferences sp = mContext.getSharedPreferences(SP_NAME, Context.MODE_PRIVATE);
    result = sp.getString(key, "");

    return result;
}

From source file:Main.java

public static boolean putBoolean(Context context, String key, boolean value) {
    SharedPreferences settings = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = settings.edit();
    editor.putBoolean(key, value);/*from  ww w .j  a v a 2 s  .  c om*/
    return editor.commit();
}

From source file:Main.java

public static void setInt(Context mContext, String name, String key, int value) {
    SharedPreferences sharedPreferences = mContext.getSharedPreferences(name, Context.MODE_PRIVATE);
    Editor editor = sharedPreferences.edit();
    editor.putInt(key, value);// ww  w . java 2  s.  co m
    editor.commit();
}

From source file:Main.java

public static String getStringValue(Context context, String key, String defValue) {
    SharedPreferences sp = context.getSharedPreferences(CONFIG_NAME, Context.MODE_PRIVATE);
    return sp.getString(key, defValue);
}