List of usage examples for android.content SharedPreferences getAll
Map<String, ?> getAll();
From source file:com.google.android.apps.authenticator.dataexport.Exporter.java
private Bundle getPreferencesBundle(SharedPreferences preferences) { Map<String, ?> preferencesMap = preferences.getAll(); if (preferencesMap == null) { preferencesMap = Collections.emptyMap(); }//from w w w. j av a 2 s .com Bundle result = new Bundle(); for (String key : preferencesMap.keySet()) { Object value = preferencesMap.get(key); if (value instanceof Boolean) { result.putBoolean(key, (Boolean) value); } else if (value instanceof Float) { result.putFloat(key, (Float) value); } else if (value instanceof Integer) { result.putInt(key, (Integer) value); } else if (value instanceof Long) { result.putLong(key, (Long) value); } else if (value instanceof String) { result.putString(key, (String) value); } else { // Can only be Set<String> at the moment (API Level 11+), which we don't use anyway. // Ignore this type of preference, since losing preferences on export is not lethal } } return result; }
From source file:com.futureplatforms.kirin.extensions.settings.PreferencesBackendImpl.java
@Override public void addPreferenceListener(final KirinPreferenceListener listener) { mPreferences.registerOnSharedPreferenceChangeListener(new OnSharedPreferenceChangeListener() { @Override/*from w ww . ja v a 2s . com*/ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { listener.onPreferenceChange(key, sharedPreferences.getAll().get(key)); } }); }
From source file:org.gluu.oxpush2.store.AndroidKeyDataStore.java
public AndroidKeyDataStore(Context context) { this.context = context; // Prepare empty U2F key pair store final SharedPreferences keySettings = context.getSharedPreferences(U2F_KEY_PAIR_FILE, Context.MODE_PRIVATE); if (keySettings.getAll().size() == 0) { if (BuildConfig.DEBUG) Log.d(TAG, "Creating empty U2K key pair store"); keySettings.edit().commit();/* ww w . j a v a2 s .com*/ } // Prepare empty U2F key counter store final SharedPreferences keyCounts = context.getSharedPreferences(U2F_KEY_COUNT_FILE, Context.MODE_PRIVATE); if (keyCounts.getAll().size() == 0) { if (BuildConfig.DEBUG) Log.d(TAG, "Creating empty U2K key counter store"); keyCounts.edit().commit(); } }
From source file:eu.intermodalics.tango_ros_streamer.ParameterNode.java
/** * Syncs the Parameter Server with all the current local shared preferences (app --> server). * @param sharedPreferences Reference to the preferences to sync. */// ww w. j a v a 2 s . co m private void uploadPreferencesToDynamicReconfigure(SharedPreferences sharedPreferences) { Map<String, ?> prefKeys = sharedPreferences.getAll(); for (Map.Entry<String, ?> entry : prefKeys.entrySet()) { if (Arrays.asList(mDynamicParamNames).contains(entry.getKey())) { if (entry.getValue() instanceof Boolean) { Boolean bool = (Boolean) entry.getValue(); callDynamicReconfigure(entry.getKey(), bool.booleanValue()); } } } }
From source file:org.getlantern.firetweet.preference.ValueDependencyCheckBoxPreference.java
private void updateEnableState() { final SharedPreferences prefs = getSharedPreferences(); if (prefs == null || mDependencyKey == null || mDependencyValues == null) return;//from ww w.jav a 2 s . co m final Map<String, ?> all = prefs.getAll(); final String valueString = ParseUtils.parseString(all.get(mDependencyKey), mDependencyValueDefault); setEnabled(ArrayUtils.contains(mDependencyValues, valueString)); }
From source file:eu.intermodalics.tango_ros_streamer.ParameterNode.java
/** * Callback that syncs Parameter Server with changes coming from the UI (app --> server). * @param sharedPreferences Reference to SharedPreferences containing the preference change. * @param key Particular preference that changed. */// ww w. j a v a 2 s . c om public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, final String key) { Map<String, ?> prefKeys = sharedPreferences.getAll(); Object prefValue = prefKeys.get(key); if (Arrays.asList(mDynamicParamNames).contains(key)) { if (prefValue instanceof Boolean) { final Boolean bool = (Boolean) prefValue; new Thread() { @Override public void run() { callDynamicReconfigure(key, bool.booleanValue()); } }.start(); } } }
From source file:org.gluu.oxpush2.store.AndroidKeyDataStore.java
@Override public List<byte[]> getKeyHandlesByIssuerAndAppId(String issuer, String application) { List<byte[]> result = new ArrayList<byte[]>(); final SharedPreferences keySettings = context.getSharedPreferences(U2F_KEY_PAIR_FILE, Context.MODE_PRIVATE); Map<String, String> keyTokens = (Map<String, String>) keySettings.getAll(); for (Map.Entry<String, String> keyToken : keyTokens.entrySet()) { String tokenEntryString = keyToken.getValue(); TokenEntry tokenEntry = new Gson().fromJson(tokenEntryString, TokenEntry.class); if (StringUtils.equals(issuer, tokenEntry.getIssuer()) && StringUtils.equals(application, tokenEntry.getApplication())) { String keyHandleKey = keyToken.getKey(); try { byte[] keyHandle = keyToKeyHandle(keyHandleKey); result.add(keyHandle);/*from w w w.j av a 2s . c o m*/ } catch (DecoderException ex) { Log.e(TAG, "Invalid keyHandle: " + keyHandleKey, ex); } } } return result; }
From source file:com.facebook.stetho.inspector.protocol.module.DOMStorage.java
@ChromeDevtoolsMethod public JsonRpcResult getDOMStorageItems(JsonRpcPeer peer, JSONObject params) throws JSONException { StorageId storage = mObjectMapper.convertValue(params.getJSONObject("storageId"), StorageId.class); ArrayList<List<String>> entries = new ArrayList<List<String>>(); String prefTag = storage.securityOrigin; if (storage.isLocalStorage) { SharedPreferences prefs = mContext.getSharedPreferences(prefTag, Context.MODE_PRIVATE); for (Map.Entry<String, ?> prefsEntry : prefs.getAll().entrySet()) { ArrayList<String> entry = new ArrayList<String>(2); entry.add(prefsEntry.getKey()); entry.add(SharedPreferencesHelper.valueToString(prefsEntry.getValue())); entries.add(entry);//from w ww . j a v a 2 s .c om } } GetDOMStorageItemsResult result = new GetDOMStorageItemsResult(); result.entries = entries; return result; }
From source file:org.gluu.com.ox_push2.store.AndroidKeyDataStore.java
public AndroidKeyDataStore(Context context) { this.context = context; // Prepare empty U2F key pair store final SharedPreferences keySettings = context.getSharedPreferences(U2F_KEY_PAIR_FILE, Context.MODE_PRIVATE); if (keySettings.getAll().size() == 0) { if (BuildConfig.DEBUG) Log.d(TAG, "Creating empty U2K key pair store"); keySettings.edit().apply();//commit(); }//ww w . ja v a 2s . com // Prepare empty U2F key counter store final SharedPreferences keyCounts = context.getSharedPreferences(U2F_KEY_COUNT_FILE, Context.MODE_PRIVATE); if (keyCounts.getAll().size() == 0) { if (BuildConfig.DEBUG) Log.d(TAG, "Creating empty U2K key counter store"); keyCounts.edit().apply();//commit(); } }
From source file:eu.faircode.adblocker.IAB.java
public void updatePurchases() throws RemoteException { // Get purchases List<String> skus = getPurchases(); SharedPreferences prefs = context.getSharedPreferences("IAB", Context.MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); for (String product : prefs.getAll().keySet()) if (!ActivityPro.SKU_DONATION.equals(product)) editor.remove(product);//w w w . jav a 2s .co m for (String sku : skus) { Log.i(TAG, "SKU=" + sku); editor.putBoolean(sku, true); } editor.apply(); }