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 String getString(String key, String defValue, Context ctx) {
    SharedPreferences sp = ctx.getSharedPreferences("config", Context.MODE_PRIVATE);
    return sp.getString(key, defValue);
}

From source file:Main.java

public static void setChatBg(Context context, String key, String url) {
    SharedPreferences spf = context.getSharedPreferences("chat", Context.MODE_PRIVATE);
    spf.edit().putString(key, url).commit();
}

From source file:Main.java

public static int restoreDistanceTravelled(Context context) {
    SharedPreferences sharedPref = context.getSharedPreferences("Distance", Context.MODE_PRIVATE);
    return sharedPref.getInt("distance", 0);
}

From source file:Main.java

public static String getUserFromPrefrence(Context context) {
    SharedPreferences sh = context.getSharedPreferences("xmeet_prefrence", Context.MODE_PRIVATE);
    return sh.getString("nickname", "");
}

From source file:Main.java

public static void deleteLoginInfo(Context context) {
    SharedPreferences.Editor editor = context.getSharedPreferences("LoginCookie", Context.MODE_PRIVATE).edit();
    editor.clear().commit();//from ww  w.j  av a2s  . com
}

From source file:Main.java

public static SharedPreferences getshared(Context context) {
    SharedPreferences preferences = context.getSharedPreferences("bbusers", Context.MODE_PRIVATE);
    return preferences;
}

From source file:Main.java

static public int getIntegerPreferences(Context context, String key) {
    SharedPreferences pref = context.getSharedPreferences("pref", Context.MODE_PRIVATE);
    return pref.getInt(key, 0);
}

From source file:Main.java

static public void removePreferences(Context context, String key) {
    SharedPreferences pref = context.getSharedPreferences("pref", Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = pref.edit();
    editor.remove(key);/*from w  w w. j  a  v  a2 s.  co m*/
    editor.commit();
}

From source file:Main.java

public static void setLong(Context context, String key, long value) {
    SharedPreferences sp = context.getSharedPreferences("configdata", Context.MODE_PRIVATE);
    sp.edit().putLong(key, value).commit();
}

From source file:Main.java

public static boolean getBoolean(Context ctx, String key, boolean defValue) {
    SharedPreferences sp = ctx.getSharedPreferences("config", Context.MODE_PRIVATE);
    return sp.getBoolean(key, defValue);
}