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 storeBoolean(Context context, String key, boolean value) {
    SharedPreferences pre = context.getSharedPreferences(STORE_NAME, Context.MODE_PRIVATE);
    pre.edit().putBoolean(STORE_KEY_PREFIX + key, value).commit();
}

From source file:Main.java

public static String getStringProperty(Context context, String key, String fileName) {
    SharedPreferences sp = context.getSharedPreferences(fileName, Context.MODE_PRIVATE);
    return sp.getString(key, null);
}

From source file:Main.java

public static String getIpPort(Context context) {
    SharedPreferences preferences = context.getSharedPreferences(IP_PORT, Context.MODE_PRIVATE);
    String ip = preferences.getString(CVALUE, "121.41.112.232:9418");
    return ip;//from   w  ww  .ja va2s . c  om
}

From source file:Main.java

public static long readLong(Context context, String key, long defaultValue) {
    SharedPreferences pre = context.getSharedPreferences(STORE_NAME, Context.MODE_PRIVATE);
    return pre.getLong(STORE_KEY_PREFIX + key, defaultValue);
}

From source file:Main.java

public static int readInteger(Context context, String key, int defaultValue) {
    SharedPreferences pre = context.getSharedPreferences(STORE_NAME, Context.MODE_PRIVATE);
    return pre.getInt(STORE_KEY_PREFIX + key, defaultValue);
}

From source file:Main.java

public static boolean getBoolean(Context context, String key, boolean defaule) {
    if (sp == null) {
        sp = context.getSharedPreferences(CACHE_FILE_NAME, Context.MODE_PRIVATE);
    }/*w w  w  . j  a  v  a 2  s  .c o  m*/
    return sp.getBoolean(key, defaule);
}

From source file:Main.java

public static String getUserPic(Context context) {
    SharedPreferences preferences = context.getSharedPreferences(USERPIC, Context.MODE_PRIVATE);
    String city = preferences.getString(CVALUE, "null");
    return city;//from www.  j ava2s. c  o m
}

From source file:Main.java

public static void setStringPref(Context context, String name, String value) {
    SharedPreferences prefs = context.getSharedPreferences(APPLICATION_NAME, Context.MODE_PRIVATE);
    Editor ed = prefs.edit();/*  ww w . j  av  a  2 s.  c o m*/
    ed.putString(name, value);
    ed.commit();
}

From source file:Main.java

public static void putFloat(Context context, String key, float value) {
    SharedPreferences sp = context.getApplicationContext().getSharedPreferences(SP_NAME, Context.MODE_PRIVATE);
    Editor editor = sp.edit();//from w w  w .ja  va2  s .  c  om
    editor.putFloat(key, value);
    editor.commit();
}

From source file:Main.java

public static void cachePullSen(Context context, float sen) {
    SharedPreferences sp = context.getSharedPreferences(CONFIG, Context.MODE_PRIVATE);
    sp.edit().putFloat(KEY_PS, sen).commit();
}