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 int getInt(Context context, String key) {
    SharedPreferences shared = context.getSharedPreferences(SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE);
    int value = shared.getInt(key, 0);
    return value;
}

From source file:Main.java

public static void setUserFromPrefrence(Context context, String nickname) {
    SharedPreferences sh = context.getSharedPreferences("xmeet_prefrence", Context.MODE_PRIVATE);
    Editor dt = sh.edit();//  w  w  w.jav  a  2s .  co m
    dt.putString("nickname", nickname);
    dt.commit();
}

From source file:Main.java

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

From source file:Main.java

public static boolean getBoolean(Context mContext, String key, boolean values) {
    SharedPreferences sp = mContext.getSharedPreferences(SHARE_NAME, Context.MODE_PRIVATE);
    return sp.getBoolean(key, values);
}

From source file:Main.java

private static SharedPreferences getSharedPreferences(Context context) {
    return context.getSharedPreferences(cheramiPackageURL, Context.MODE_PRIVATE);
}

From source file:Main.java

public static HashMap<String, String> restoreDistanceAndLocation(Context context) {
    SharedPreferences sharedPref = context.getSharedPreferences("DistanceAndLocation", Context.MODE_PRIVATE);
    String[] keyList = { "longitude", "latitude", "kmTravelled" };
    HashMap<String, String> values = new HashMap<>();
    for (String key : keyList)
        values.put(key, sharedPref.getString(key, null));
    return values;
}

From source file:Main.java

public static void saveString(Context context, String key, String values) {
    SharedPreferences preferences = context.getSharedPreferences(SP_NAME, Context.MODE_PRIVATE);
    preferences.edit().putString(key, values).commit();
}

From source file:Main.java

public static boolean getBoolean(Context context, String key, boolean defValue) {
    if (sp == null) {
        sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
    }//from   w ww. ja v  a2s .  c o  m
    return sp.getBoolean(key, defValue);
}

From source file:Main.java

public static void putString(Context context, String title, String content) {
    SharedPreferences sp = context.getSharedPreferences(FILENAME, Context.MODE_PRIVATE);
    SharedPreferences.Editor edit = sp.edit();
    edit.putString(title, content);/*from   www.j  a  va  2 s.co m*/
    edit.commit();
}

From source file:Main.java

public static Map<String, ?> getAll(Context context) {
    SharedPreferences sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE);
    return sp.getAll();
}