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

private static final String getLastLoginAccount(Context sp) {
    return sp.getSharedPreferences("yuxun", sp.MODE_PRIVATE).getString("lastAccount", null);
}

From source file:Main.java

public static void setRatingNotiFalse(Context context) {
    context.getSharedPreferences("Settings", Context.MODE_PRIVATE).edit().putBoolean("rating_noti", false)
            .commit();//  ww w  .  j  av a2s .c o m
}

From source file:Main.java

public static void logout(Context context) {
    context.getSharedPreferences(LOGIN_PREFERENCE, Context.MODE_PRIVATE).edit()
            .putBoolean(PREFERENCE_AUTHORIZED_KEY, false).apply();
}

From source file:Main.java

public static void setAuthorized(Context context) {
    context.getSharedPreferences(LOGIN_PREFERENCE, Context.MODE_PRIVATE).edit()
            .putBoolean(PREFERENCE_AUTHORIZED_KEY, true).apply();
}

From source file:Main.java

public static SharedPreferences appsPrefs(Context c) {
    return c.getSharedPreferences(PREF_FILE_APPS, Context.MODE_PRIVATE);
}

From source file:Main.java

/**
 * Deletes the logged athlete from the android shared preferences
 *//*from   w  w  w. ja v a 2 s . co  m*/
public static void removeLoggedAthlete(Context context) {
    context.getSharedPreferences(PREFERENCES_FILE, Context.MODE_PRIVATE).edit().remove(LOGGED_ATHLETE).commit();
}

From source file:Main.java

public static Set<String> getFavorities(Context c) {
    return c.getSharedPreferences(PREFS_NAME, 0).getStringSet(FAVORITIES, new HashSet<String>());
}

From source file:Main.java

public static SharedPreferences getSharedPref(Context c) {
    return c.getSharedPreferences(c.getPackageName(), Context.MODE_PRIVATE);
}

From source file:Main.java

public static SharedPreferences myGetSharedPreferences(Context ctxt) {
    return ctxt.getSharedPreferences("usersettings", 0);
}

From source file:Main.java

private static SharedPreferences getSp(Context context) {
    return context.getSharedPreferences("hask", 0);
}