Example usage for android.content Context getSharedPreferences

List of usage examples for android.content Context getSharedPreferences

Introduction

In this page you can find the example usage for android.content Context getSharedPreferences.

Prototype

public abstract SharedPreferences getSharedPreferences(File file, @PreferencesMode int mode);

Source Link

Document

Retrieve and hold the contents of the preferences file, returning a SharedPreferences through which you can retrieve and modify its values.

Usage

From source file:Main.java

public static void put(Context arg2, String arg3, String value) {
    arg2.getSharedPreferences("marsroot", 0).edit().putString(arg3, value).commit();
}

From source file:Main.java

public static int getChangeMode(Context ctx) {
    SharedPreferences sp = ctx.getSharedPreferences("config_mode", Context.MODE_PRIVATE);
    return sp.getInt(Mode, MODE_DAY);
}

From source file:Main.java

public static SharedPreferences getApplicationIconBadgeSettings(Context context) {
    return context.getSharedPreferences("notificationsiconbadge", Context.MODE_WORLD_READABLE);
}

From source file:Main.java

public static SharedPreferences getPreferences(Context context) {
    return context.getSharedPreferences(PREF_NAMESPACE, Context.MODE_PRIVATE);
}

From source file:Main.java

public static int loadIntSavedPreferences(String key, Context ctx) {
    SharedPreferences sp = ctx.getSharedPreferences(sharedPrefsFile, Context.MODE_PRIVATE);
    int name = sp.getInt(key, -1);
    return name;//  ww w  .j  a  v a2s  .  co  m
}

From source file:Main.java

public static void init(Context context) {
    sharedPreferences = context.getSharedPreferences("config", 0);
    editor = sharedPreferences.edit();/*from  ww  w.  j  a  va 2s.  c  om*/
}

From source file:Main.java

public static String loadStringSavedPreferences(String key, Context ctx) {
    SharedPreferences sp = ctx.getSharedPreferences(sharedPrefsFile, Context.MODE_PRIVATE);
    String name = sp.getString(key, "");
    return name;/*from  w  ww. j  a va2s.  c o m*/
}

From source file:Main.java

public static void clearSave(Context context) {
    settings = context.getSharedPreferences(XML_Settings, 0);
    for (String name : settings.getAll().keySet()) {
        saveSharedPreString(context, name, "");
    }//from   w w  w.j a  va  2 s .  co  m
}

From source file:Main.java

public static void putString(Context context, String key, String value) {
    context.getSharedPreferences("atguigu", Context.MODE_PRIVATE).edit().putString(key, value).commit();
}

From source file:Main.java

public static int getNotReadCount(Context context) {
    SharedPreferences spf = context.getSharedPreferences("msg", Context.MODE_PRIVATE);
    return spf.getInt("count", 0);
}