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 Map<String, ?> getAll(Context context, String file_name) {
    SharedPreferences sp = context.getSharedPreferences(file_name, Context.MODE_PRIVATE);
    return sp.getAll();
}

From source file:Main.java

public static void setChangeMode(Context ctx, int mode) {
    SharedPreferences sp = ctx.getSharedPreferences("config_mode", Context.MODE_PRIVATE);
    sp.edit().putInt(Mode, mode).commit();
}

From source file:Main.java

public static String getMemberID(Context context) {
    SharedPreferences userPreferences = context.getSharedPreferences("umeng_general_config",
            Context.MODE_PRIVATE);
    String string = userPreferences.getString("ID", null);
    return string;
}

From source file:Main.java

public static String getUserToken(Context context) {
    SharedPreferences userPreferences = context.getSharedPreferences("umeng_general_config",
            Context.MODE_PRIVATE);
    String string = userPreferences.getString("jdycode", null);
    return string;
}

From source file:Main.java

public static String readSharedSetting(Context ctx, String settingName, String defaultValue) {
    SharedPreferences sharedPref = ctx.getSharedPreferences("OnBoardFile", Context.MODE_PRIVATE);
    return sharedPref.getString(settingName, defaultValue);
}

From source file:Main.java

public static void setUserInfo(Context context, String uname, String upwd) {
    SharedPreferences preferences = context.getSharedPreferences("UserInfo.txt", Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = preferences.edit();
    editor.putString("uname", uname);
    editor.putString("upwd", upwd);
    editor.commit();//from   w w  w  .  jav a 2  s.c o  m
}

From source file:Main.java

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

From source file:Main.java

public static String getUserPassword(Context context) {
    String upwd = "";
    SharedPreferences preferences = context.getSharedPreferences("UserInfo.txt", Context.MODE_PRIVATE);
    upwd = preferences.getString("upwd", "");
    return upwd;//from  w w w  . jav a  2s  . c  o m
}

From source file:Main.java

public static boolean getBooleanProperty(final Context context, String propertyName) {
    SharedPreferences preferences = context.getSharedPreferences("YTWPreferences", Context.MODE_PRIVATE);
    return preferences.getBoolean(propertyName, false);
}

From source file:Main.java

public static boolean keyExistsInSharedPreference(Context context, String key) {
    return context.getSharedPreferences(SHARED_PREFERENCES, Context.MODE_PRIVATE).contains(key);
}