List of usage examples for android.content SharedPreferences getAll
Map<String, ?> getAll();
From source file:com.facebook.stetho.inspector.protocol.module.DOMStorage.java
@ChromeDevtoolsMethod public void setDOMStorageItem(JsonRpcPeer peer, JSONObject params) throws JSONException, JsonRpcException { StorageId storage = mObjectMapper.convertValue(params.getJSONObject("storageId"), StorageId.class); String key = params.getString("key"); String value = params.getString("value"); if (storage.isLocalStorage) { SharedPreferences prefs = mContext.getSharedPreferences(storage.securityOrigin, Context.MODE_PRIVATE); Object existingValue = prefs.getAll().get(key); try {//from w w w.java 2s . co m if (existingValue == null) { throw new DOMStorageAssignmentException( "Unsupported: cannot add new key " + key + " due to lack of type inference"); } else { SharedPreferences.Editor editor = prefs.edit(); try { assignByType(editor, key, SharedPreferencesHelper.valueFromString(value, existingValue)); editor.apply(); } catch (IllegalArgumentException e) { throw new DOMStorageAssignmentException( String.format(Locale.US, "Type mismatch setting %s to %s (expected %s)", key, value, existingValue.getClass().getSimpleName())); } } } catch (DOMStorageAssignmentException e) { CLog.writeToConsole(mDOMStoragePeerManager, Console.MessageLevel.ERROR, Console.MessageSource.STORAGE, e.getMessage()); // Force the DevTools UI to refresh with the old value again (it assumes that the set // operation succeeded). Note that we should be able to do this by throwing // JsonRpcException but the UI doesn't respect setDOMStorageItem failure. if (prefs.contains(key)) { mDOMStoragePeerManager.signalItemUpdated(storage, key, value, SharedPreferencesHelper.valueToString(existingValue)); } else { mDOMStoragePeerManager.signalItemRemoved(storage, key); } } } }
From source file:com.piusvelte.imgpagur.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { //TODO setTheme super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); SharedPreferences sharedPrefs = getSharedPreferences(getString(R.string.app_name), Context.MODE_PRIVATE); for (Map.Entry<String, String> entry : ((Map<String, String>) sharedPrefs.getAll()).entrySet()) { imgFeeds.add(new ImgFeed(entry.getKey(), entry.getValue())); }//from w ww.ja v a 2 s . c om viewPager = (ViewPager) findViewById(R.id.pager); adapter = new ImgPagurPagerAdapter(getSupportFragmentManager()); actionBar = getSupportActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); viewPager.setAdapter(adapter); viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } }); for (int i = 0, c = adapter.getCount(); i < c; i++) { actionBar.addTab(actionBar.newTab().setText(adapter.getPageTitle(i)).setTabListener(this)); } }
From source file:com.abiansoftware.lib.reader.AbianReaderApplication.java
private void loadReadUrlList() { if (m_readUrlArrayList == null) { m_readUrlArrayList = new ArrayList<String>(); }/*from ww w .j a v a2 s. c om*/ m_readUrlArrayList.clear(); SharedPreferences preferences = getSharedPreferences(READ_URL_PREFERENCES, MODE_PRIVATE); Map<String, ?> prefMap = preferences.getAll(); Set<String> mapKeys = prefMap.keySet(); for (String thisKey : mapKeys) { if (prefMap.get(thisKey) instanceof String) { String thisValue = (String) prefMap.get(thisKey); if (thisValue.equalsIgnoreCase(KEY_READ_URL_LIST)) { m_readUrlArrayList.add(thisKey); } } } }
From source file:com.xtensive.plugins.pdfviewer.PDFViewer.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { Log.d("ACTIVITY RESULT PLUGIN", "LINK CLICKED " + requestCode); //this.cb.sendPluginResult(); SharedPreferences mList = cordova.getActivity().getSharedPreferences(MuPDFActivity.PERSONAL_LIST, Activity.MODE_PRIVATE);/*from w w w . j a v a 2 s. c om*/ Log.d("PLUGIN LINKS", String.valueOf(mList.getAll())); SharedPreferences.Editor editor = mList.edit(); editor.clear(); editor.commit(); }
From source file:eu.faircode.netguard.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)) { Log.i(TAG, "removing SKU=" + product); editor.remove(product);/*from w w w . j ava2 s. c o m*/ } for (String sku : skus) { Log.i(TAG, "adding SKU=" + sku); editor.putBoolean(sku, true); } editor.apply(); }
From source file:org.gluu.com.ox_push2.store.AndroidKeyDataStore.java
@Override public List<LogInfo> getLogs() { final SharedPreferences logSettings = context.getSharedPreferences(LOGS_STORE, Context.MODE_PRIVATE); Map<String, String> logsMap = (Map<String, String>) logSettings.getAll(); List<LogInfo> logs = new ArrayList<LogInfo>(); for (Map.Entry<String, String> log : logsMap.entrySet()) { logs.add(new Gson().fromJson(log.getValue(), LogInfo.class)); }/*from ww w. j a v a 2s.com*/ return logs; }
From source file:itkach.aard2.SettingsListAdapter.java
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String s) { this.userStyleData = sharedPreferences.getAll(); this.userStyleNames = new ArrayList<String>(this.userStyleData.keySet()); Collections.sort(userStyleNames); notifyDataSetChanged();/*from ww w . j a va 2 s. com*/ }
From source file:edu.pdx.cecs.orcycle.UserFeedbackUploader.java
/** * * @return/* w w w. j a va2 s .co m*/ * @throws JSONException */ private JSONObject getUserJSON() throws JSONException { String userFeedback = null; JSONObject userJson = null; SharedPreferences settings = mCtx.getSharedPreferences(UserFeedbackActivity.PREFS_USER_FEEDBACK_UPLOAD, Context.MODE_PRIVATE); Map<String, ?> prefs = settings.getAll(); for (Entry<String, ?> p : prefs.entrySet()) { int key = Integer.parseInt(p.getKey()); // CharSequence value = (CharSequence) p.getValue(); switch (key) { case UserFeedbackActivity.PREF_FEEDBACK: userFeedback = (String) p.getValue(); break; } } if (null != userFeedback) { if (null != (userJson = new JSONObject())) { userJson.put(USER_FEEDBACK, userFeedback); } } return userJson; }
From source file:org.gluu.com.ox_push2.store.AndroidKeyDataStore.java
@Override public List<String> getTokenEntries() { List<String> result = new ArrayList<String>(); 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); String keyHandleKey = keyToken.getKey(); try {/* w w w .ja va 2 s . c o m*/ byte[] keyHandle = keyToKeyHandle(keyHandleKey); tokenEntry.setKeyHandle(keyHandle); } catch (DecoderException e) { Log.e(TAG, "Decoder exception: ", e); } tokenEntryString = new Gson().toJson(tokenEntry); result.add(tokenEntryString); } return result; }
From source file:org.gluu.com.ox_push2.store.AndroidKeyDataStore.java
@Override public void changeKeyHandleName(String keyHandleID, String newName) { 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 (keyHandleID != null && keyHandleID.equals(tokenEntry.getIssuer())) { tokenEntry.setKeyName(newName); SharedPreferences tokenSettings = context.getSharedPreferences(U2F_KEY_PAIR_FILE, Context.MODE_PRIVATE); String tokenEntryStr = new Gson().toJson(tokenEntry); String keyHandleKey = keyHandleToKey(tokenEntry.getKeyHandle()); tokenSettings.edit().putString(keyHandleKey, tokenEntryStr).apply();//commit(); return; }//from ww w . j ava 2 s .c o m } }