Example usage for android.preference PreferenceManager getDefaultSharedPreferences

List of usage examples for android.preference PreferenceManager getDefaultSharedPreferences

Introduction

In this page you can find the example usage for android.preference PreferenceManager getDefaultSharedPreferences.

Prototype

public static SharedPreferences getDefaultSharedPreferences(Context context) 

Source Link

Document

Gets a SharedPreferences instance that points to the default file that is used by the preference framework in the given context.

Usage

From source file:Main.java

public static String getAccountName(Context context) {
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
    return sharedPreferences.getString("account_name_preference", "");
}

From source file:Main.java

public static void deleteAllPreference(Context context) {
    SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
    Editor edit = pref.edit();// w w  w  . j av a2  s . com
    edit.clear();
    edit.commit();
}

From source file:Main.java

public static void savePreferencesForReasonCode(Context context, String key, String value) {
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
    SharedPreferences.Editor editor = sharedPreferences.edit();
    editor.putString(key, value);//w  w  w.j  av  a  2  s  . c o  m
    editor.commit();
}

From source file:Main.java

public static String getBindStr(Context context, String bindStr) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    return sp.getString(bindStr, "");
}

From source file:Main.java

public static void setLogText(Context context, String text) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    Editor editor = sp.edit();//from  w  w w .  j a v a  2s  .c om
    editor.putString("log_text", text);
    editor.commit();
}

From source file:Main.java

public static String getPrefTheme(final Context context) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    return sp.getString(PREF_THEME, "Default");
}

From source file:Main.java

public static String getUserEmail(final Context context) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    return sp.getString(PREF_EMAIL, null);
}

From source file:Main.java

public static boolean isRootEnabled(Context context) {
    SharedPreferences preferenceScreen = PreferenceManager.getDefaultSharedPreferences(context);
    return preferenceScreen.getBoolean("isRootEnabled", false);
}

From source file:Main.java

public static boolean getLoginState(Context context) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    return prefs.getBoolean(STATE_LOGIN, false);
}

From source file:Main.java

public static boolean isHeartbeatFixerEnabled(Context context) {
    return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(PREF_KEY_FIXER_STATE, false);
}