List of usage examples for android.preference PreferenceManager getDefaultSharedPreferences
public static SharedPreferences getDefaultSharedPreferences(Context context)
From source file:Main.java
public static String getChosenAccountName(final Context context) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); return sp.getString(PREF_CHOSEN_ACCOUNT, null); }
From source file:Main.java
/** * Removes the authToken and account name from storage *//*from w w w. j a va 2 s . c om*/ public static void ClearAuthToken(Context applicationContext) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(applicationContext); SharedPreferences.Editor editor = prefs.edit(); editor.remove("GDRIVE_AUTH_TOKEN"); editor.remove("GDRIVE_ACCOUNT_NAME"); editor.commit(); }
From source file:Main.java
public static void setAttendeeAtVenue(final Context context, final boolean isAtVenue) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); sp.edit().putBoolean(PREF_ATTENDEE_AT_VENUE, isAtVenue).commit(); }
From source file:Main.java
public static boolean isOnlyRemoteAttendee(final Context context) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); return sp.getBoolean(PREF_ONLY_REMOTE_ATTENDEE_, true); }
From source file:Main.java
public static void setCredentials(final Context context, String login, String password) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); sp.edit().putString(PREF_SAVED_LOGIN, login).putString(PREF_SAVED_PASSWORD, password).commit(); }
From source file:Main.java
public static void setMigrationUpdateHandled(Context context) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); preferences.edit().putBoolean(KEY_MIGRATION_UPDATED_HANDLED, true).apply(); }
From source file:Main.java
/** * Set whether speaker mode is in use.//from w ww .jav a 2 s. c om * @param context the Context * @param isSpeaker speaker state */ public static void setIsSpeakerModeOnFocusLost(Context context, boolean isSpeaker) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean(FM_IS_SPEAKER_MODE, isSpeaker); editor.commit(); }
From source file:Main.java
static public synchronized boolean checkConnectivity(Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); // mMobile = prefs.getBoolean(ENUMPrefs.ENUM_PREF_MOBILE, false); mOnline = false;/* w ww . j av a 2 s .co m*/ ConnectivityManager mCmgr = (ConnectivityManager) context.getSystemService(Service.CONNECTIVITY_SERVICE); NetworkInfo ni = mCmgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI); if (ni != null && ni.isConnected()) { /* wifi is on */ mOnline = true; } else { if (mMobile) { /* if mobile is active and EDGE or better, we're good */ ni = mCmgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); if (ni != null && ni.isConnected()) { mOnline = (ni.getSubtype() >= TelephonyManager.NETWORK_TYPE_EDGE); } } } return mOnline; }
From source file:Main.java
public static void setUsingLocalTime(final Context context, final boolean usingLocalTime) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); sp.edit().putBoolean(PREF_LOCAL_TIMES, usingLocalTime).commit(); }
From source file:Main.java
/** * Saves the counter value in the preference storage. If <code>value</code> * is negative, then the value will be removed from the preferences. *//*from w w w . ja v a2 s. c om*/ public static void saveCounterToPreference(Context context, int value) { SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context); if (value < 0) { // we want to remove pref.edit().remove(PREF_KEY_COUNTER).apply(); } else { pref.edit().putInt(PREF_KEY_COUNTER, value).apply(); } }