List of usage examples for android.preference PreferenceManager getDefaultSharedPreferences
public static SharedPreferences getDefaultSharedPreferences(Context context)
From source file:Main.java
public static void setUiDisabledForMigration(Context context, boolean uiDisabled) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); preferences.edit().putBoolean(KEY_UI_DISABLED_FOR_MIGRATION, uiDisabled).apply(); }
From source file:Main.java
public static boolean isFlashSupported(Camera camera, Context context) { mPreferences = PreferenceManager.getDefaultSharedPreferences(context); if (camera != null) { Camera.Parameters mParameters = camera.getParameters(); if (mParameters.getFlashMode() == null) { mPrefFlash = mPreferences.edit().putBoolean("mPrefFlash", false).commit(); return false; }/*w w w .j a va 2s .co m*/ List<String> mSupportedFlashModes = mParameters.getSupportedFlashModes(); if (mSupportedFlashModes == null || mSupportedFlashModes.isEmpty() || mSupportedFlashModes.size() == 1 && mSupportedFlashModes.get(0).equals(Camera.Parameters.FLASH_MODE_OFF)) { mPrefFlash = mPreferences.edit().putBoolean("mPrefFlash", false).commit(); return false; } } else { mPrefFlash = mPreferences.edit().putBoolean("mPrefFlash", false).commit(); return false; } mPrefFlash = mPreferences.edit().putBoolean("mPrefFlash", true).commit(); return true; }
From source file:Main.java
/** * Set the last searched location/*from w ww . ja v a 2 s . c o m*/ */ public static void setLastSearchedLocation(Context context, double latitude, double longitude) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor editor = prefs.edit(); String strLatitude = Double.valueOf(latitude).toString(); String strLongitude = Double.valueOf(longitude).toString(); editor.putString(FM_LOCATION_LATITUDE, strLatitude); editor.putString(FM_LOCATION_LONGITUDE, strLongitude); editor.commit(); }
From source file:Main.java
/** * Clears all the persisted responses.// ww w . j a v a 2s .c o m */ public static void clearResponses(Context context) { SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context); pref.edit().remove(PREF_SESSION_ID).apply(); for (String name : PREF_RESPONSES) { pref.edit().remove(name).apply(); } }
From source file:Main.java
/** * Get whether speaker mode is in use when audio focus lost. * @param context the Context/* w ww .ja va 2 s . c om*/ * @return true for speaker mode, false for non speaker mode */ public static boolean getIsSpeakerModeOnFocusLost(Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); return prefs.getBoolean(FM_IS_SPEAKER_MODE, false); }
From source file:Main.java
/** * Removes the authToken and account name from storage * * @param applicationContext/*from ww w .ja va 2s . c o m*/ */ public static void ClearAuthToken(Context applicationContext) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(applicationContext); SharedPreferences.Editor editor = prefs.edit(); editor.remove("GDOCS_AUTH_TOKEN"); editor.remove("GDOCS_ACCOUNT_NAME"); editor.commit(); }
From source file:Main.java
/** * Get the latest searched location//w w w . j a v a2s. com * @return the list of latitude and longitude */ public static double[] getLastSearchedLocation(Context context) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String strLatitude = prefs.getString(FM_LOCATION_LATITUDE, "0.0"); String strLongitude = prefs.getString(FM_LOCATION_LONGITUDE, "0.0"); double latitude = Double.valueOf(strLatitude); double longitude = Double.valueOf(strLongitude); return new double[] { latitude, longitude }; }
From source file:Main.java
@SuppressLint("SetJavaScriptEnabled") public static void webView_Settings(final Activity from, final WebView webView) { SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(from); String fontSizeST = sharedPref.getString("font", "100"); int fontSize = Integer.parseInt(fontSizeST); webView.getSettings().setAppCachePath(from.getApplicationContext().getCacheDir().getAbsolutePath()); webView.getSettings().setAllowFileAccess(true); webView.getSettings().setAppCacheEnabled(true); webView.getSettings().setBuiltInZoomControls(true); webView.getSettings().setDisplayZoomControls(false); webView.getSettings().setTextZoom(fontSize); webView.getSettings().setGeolocationEnabled(false); webView.getSettings().setDomStorageEnabled(true); webView.getSettings().setUseWideViewPort(true); webView.getSettings().setLoadWithOverviewMode(true); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT); // load online by default }
From source file:Main.java
/** * Returns whether the app is authorized to perform Google API operations * * @param applicationContext// w w w .j a va 2s.com * @return */ public static boolean IsLinked(Context applicationContext) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(applicationContext); String gdocsAuthToken = prefs.getString("GDOCS_AUTH_TOKEN", ""); String gdocsAccount = prefs.getString("GDOCS_ACCOUNT_NAME", ""); return gdocsAuthToken.length() > 0 && gdocsAccount.length() > 0; }