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 putString(Context context, String key, String values) {

    if (sp == null) {
        sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);

    }//from   www.  j a  v a2 s .c o m
    Editor editor = sp.edit();
    editor.putString(key, values);
    editor.commit();

}

From source file:Main.java

public static boolean loadAutoRefreshFromPreference(Context c) {
    SharedPreferences preferences = c.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
    return preferences.getBoolean(PREF_AUTO_REFRESH, true);
}

From source file:Main.java

public static void remove(Context context, String key) {
    SharedPreferences sp = context.getApplicationContext().getSharedPreferences(SP_NAME, Context.MODE_PRIVATE);
    Editor editor = sp.edit();//from   w ww.  j a v  a  2  s. c  o m
    editor.remove(key);
    editor.commit();
}

From source file:Main.java

public static void setDesktopBlocked(Context context, boolean block) {
    SharedPreferences sp = sp = context.getSharedPreferences(ALMOSTNEXUS_PREFERENCES, Context.MODE_PRIVATE);
    ;//from w  w w  .j a v a  2s.c  o  m
    SharedPreferences.Editor editor = sp.edit();
    editor.putBoolean("desktopBlocked", block);
    editor.commit();
}

From source file:Main.java

public static String getThemePackageName(Context context, String default_theme) {
    SharedPreferences sp = context.getSharedPreferences(ALMOSTNEXUS_PREFERENCES, Context.MODE_PRIVATE);
    return sp.getString("themePackageName", default_theme);
}

From source file:Main.java

private static final SharedPreferences getSharedPreference(Context context) {
    return context.getSharedPreferences(EASY_SOCIAL_FACEBOOK_PREFERENCE_NAME, Context.MODE_PRIVATE);
}

From source file:Main.java

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

    return sp.getBoolean(key, defValue);
}

From source file:Main.java

public static String getStringPreference(Context context, String key) {
    SharedPreferences sharedPreferences = context.getSharedPreferences(SHARED_PREFERENCE_TAG,
            Context.MODE_PRIVATE);
    return sharedPreferences.getString(key, "");
}

From source file:Main.java

public static void addBooleanValueInSharedPreference(Context context, String key, boolean value) {
    SharedPreferences sharedPref = context.getSharedPreferences(SHARED_PREFERENCES, Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = sharedPref.edit();
    editor.putBoolean(key, value);//from  www .j  a  va2 s .  c om
    editor.apply();
}

From source file:Main.java

public static void putQQid(Context context, String qqid) {
    SharedPreferences preferences = context.getSharedPreferences(QQ, Context.MODE_PRIVATE);
    preferences.edit().putString(QQ_ID, qqid).commit();
}