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 int getMaxIndex(Context mContext) {
    SharedPreferences settings = mContext.getSharedPreferences("clock", Context.MODE_PRIVATE);
    return settings.getInt(MAX_INDEX, 0);
}

From source file:Main.java

public static void setGuided(Context context) {
    SharedPreferences prefe = context.getSharedPreferences(USER_GUIDE_FILE_NAME, 0);
    Editor editor = prefe.edit();/*from   w  ww.ja  v a2s  .  c  om*/
    editor.putBoolean("isguide", true);
    editor.commit();
}

From source file:Main.java

public static void clearUser(Context context) {
    SharedPreferences preferences = context.getSharedPreferences("USER", Context.MODE_PRIVATE);
    preferences.edit().clear().commit();
}

From source file:Main.java

public static Set<String> getAllFaceIds(String personId, Context context) {
    SharedPreferences faceIdSet = context.getSharedPreferences(personId + "FaceIdSet", Context.MODE_PRIVATE);
    return faceIdSet.getStringSet("FaceIdSet", new HashSet<String>());
}

From source file:Main.java

public static float getProtToday(Context c) {
    sharedpreferences = c.getSharedPreferences(SHARED_PREF_FILE_NAME, 0);
    float result = sharedpreferences.getFloat(PROT_TODAY_PREF_NAME, 0);
    //Log/*  w  w  w  .j a va2 s.  co  m*/
    return result;
}

From source file:Main.java

public static String getPhone(Context context) {
    SharedPreferences preferences = context.getSharedPreferences(SETTINGS, Context.MODE_PRIVATE);
    return preferences.getString(PHONE, "");
}

From source file:Main.java

public static boolean getBoolean(Context context, String key) {
    SharedPreferences sp = context.getSharedPreferences("tron", Context.MODE_PRIVATE);
    return sp.getBoolean(key, false);
}

From source file:Main.java

public static boolean getBoolean(Context context, String key) {
    SharedPreferences sp = context.getSharedPreferences("liu", Context.MODE_PRIVATE);
    return sp.getBoolean(key, false);
}

From source file:Main.java

public static boolean getBoolean(Context context, String key) {
    SharedPreferences sp = context.getSharedPreferences("7Yan", context.MODE_PRIVATE);
    return sp.getBoolean(key, false);
}

From source file:Main.java

public static void appUsageNumber(Context context) {
    SharedPreferences settings = context.getSharedPreferences("Settings", Context.MODE_PRIVATE);
    Integer number = settings.getInt("usage_num", 0);

    settings.edit().putInt("usage_num", number + 1).commit();
}