Java Code Examples for android.content.SharedPreferences#getAll()
The following examples show how to use
android.content.SharedPreferences#getAll() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WalletStorage.java From bcm-android with GNU General Public License v3.0 | 6 votes |
public void checkForWallets(Context c) { // Full wallets File[] wallets = c.getFilesDir().listFiles(); if (wallets == null) { return; } for (int i = 0; i < wallets.length; i++) { if (wallets[i].isFile()) { if (wallets[i].getName().length() == 40) { add(new FullWallet("0x" + wallets[i].getName(), wallets[i].getName()), c); } } } // Watch only SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(c); Map<String, ?> allEntries = preferences.getAll(); for (Map.Entry<String, ?> entry : allEntries.entrySet()) { if (entry.getKey().length() == 42 && !mapdb.contains(entry.getKey())) add(new WatchWallet(entry.getKey()), c); } if (mapdb.size() > 0) save(c); }
Example 2
Source File: BaseUrlUtil.java From BaseUrlManager with MIT License | 6 votes |
/** * 获取UrlInfo集合 * @param context * @return */ public static List<UrlInfo> getUrlInfos(@NonNull Context context){ SharedPreferences sp = getSharedPreferences(context); List<UrlInfo> list = new ArrayList<>(); try{ Map<String,Long> map = (Map<String,Long>)sp.getAll(); if(map!=null){ for(Map.Entry<String,Long> entry : map.entrySet()){ list.add(new UrlInfo(entry.getKey(),entry.getValue())); } } Collections.sort(list); }catch (Exception e){ e.printStackTrace(); } return list; }
Example 3
Source File: LVCachePlugin.java From VideoOS-Android-SDK with GNU General Public License v3.0 | 6 votes |
@Override public Varargs invoke(Varargs args) { int fixIndex = VenvyLVLibBinder.fixIndex(args); LuaValue luaKey = args.arg(fixIndex + 1); String key = luaValueToString(luaKey); SharedPreferences spf = App.getContext().getSharedPreferences(cacheFileName, Activity.MODE_PRIVATE); final Map<String, ?> spfValues = spf.getAll(); if (spfValues == null) { return null; } LuaTable table = new LuaTable(); Set<String> keys = spfValues.keySet(); for (String s : keys) { //包含指定key if (s.contains(key)) { String value = (String) spfValues.get(s); if (value == null) { value = ""; } table.set(LuaValue.valueOf(s), LuaValue.valueOf(value)); } } return table; }
Example 4
Source File: MostLaunchedHelper.java From paper-launcher with MIT License | 5 votes |
public void setupIfNeeded(Context context, List<ApplicationInfo> applicationInfoList) { SharedPreferences preferences = getSharedPreferences(context); Map<String, ?> allPreferences = preferences.getAll(); for (ApplicationInfo applicationInfo : applicationInfoList) { if (!allPreferences.containsKey(applicationInfo.packageName)) { preferences.edit().putInt(applicationInfo.packageName, 0).apply(); } } }
Example 5
Source File: AndroidSystemSetting.java From java-unified-sdk with Apache License 2.0 | 5 votes |
public Map<String, Object> getAll(String keyZone) { if (null == this.context) { return null; } SharedPreferences setting = this.context.getSharedPreferences(keyZone, Context.MODE_PRIVATE); return (Map<String, Object>)setting.getAll(); }
Example 6
Source File: ProvisioningSettings.java From Android-nRF-Mesh-Library with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void addAppKeys() { final SharedPreferences preferences = mContext.getSharedPreferences(APPLICATION_KEYS, Context.MODE_PRIVATE); final Map<String, ?> keys = preferences.getAll(); if (!keys.isEmpty()) { appKeys.clear(); for (int i = 0; i < keys.size(); i++) { appKeys.add(i, String.valueOf(keys.get(String.valueOf(i)))); } } else { appKeys.add(SecureUtils.generateRandomApplicationKey().toUpperCase(Locale.US)); appKeys.add(SecureUtils.generateRandomApplicationKey().toUpperCase(Locale.US)); appKeys.add(SecureUtils.generateRandomApplicationKey().toUpperCase(Locale.US)); } saveApplicationKeys(); }
Example 7
Source File: MostLaunchedHelper.java From paper-launcher with MIT License | 5 votes |
@SuppressWarnings("unchecked") private List<Map.Entry<String, Integer>> getAllEntries(Context context) { final SharedPreferences preferences = getSharedPreferences(context); final Map<String, ?> allPreferences = preferences.getAll(); return DictionaryUtil.sortHashMapByValues((HashMap<String, Integer>) allPreferences); }
Example 8
Source File: SPUtil.java From FastLib with Apache License 2.0 | 4 votes |
public static Map<String, ?> getAll(Context context, String fileName) { SharedPreferences sp = context.getSharedPreferences(fileName, Context.MODE_PRIVATE); return sp.getAll(); }
Example 9
Source File: SPUtils.java From AccountBook with GNU General Public License v3.0 | 4 votes |
/** * 返回所有的键值对 */ public static Map<String, ?> getAllKeyValue(Context context) { SharedPreferences sp = context.getSharedPreferences(getSpName(context), Context.MODE_PRIVATE); return sp.getAll(); }
Example 10
Source File: TextFrag.java From PowerFileExplorer with GNU General Public License v3.0 | 4 votes |
public File[] getHistory() { // get history class FileInfo { String path; long lastaccess; } SharedPreferences sp = fragActivity.getSharedPreferences(SettingsActivity.PREF_HISTORY, Activity.MODE_PRIVATE); ArrayList<FileInfo> fl = new ArrayList<FileInfo>(); fl.removeAll(fl); Map<String, ?> map = sp.getAll(); // enumerate all of history for (Entry<String, ?> entry : map.entrySet()) { Object val = entry.getValue(); if (val instanceof String) { String[] vals = ((String)val).split(","); if (vals.length >= 3) { try { FileInfo fi = new FileInfo(); fi.path = entry.getKey(); fi.lastaccess = Long.parseLong(vals[2]); if ( new File(fi.path).exists() ){ fl.add(fi); } } catch (Exception e) { } } } } if (fl.size() == 0) { return null; } Collections.sort(fl, new Comparator<FileInfo>() { public int compare(FileInfo object1, FileInfo object2) { if (object2.lastaccess < object1.lastaccess) { return -1; } else if (object2.lastaccess > object1.lastaccess) { return 1; } return 0; } }); int historymax = fl.size(); if (historymax > 20) { historymax = 20; } File[] items = new File[historymax]; int max = fl.size(); for (int i = 0; i < max; i++) { if (i < historymax) { File f = new File(fl.get(i).path); items[i] = f; } else { // remove a record over 20 counts sp.edit().remove(fl.get(i).path); } } sp.edit().commit(); return items; }
Example 11
Source File: VMSPUtil.java From VMLibrary with Apache License 2.0 | 4 votes |
/** * 返回所有的键值对 */ public static Map<String, ?> getAll(Context context) { SharedPreferences sp = getSharedPreferences(context); return sp.getAll(); }
Example 12
Source File: SPUtil.java From UIWidget with Apache License 2.0 | 4 votes |
public static Map<String, ?> getAll(Context context, String fileName) { SharedPreferences sp = context.getSharedPreferences(fileName, Context.MODE_PRIVATE); return sp.getAll(); }
Example 13
Source File: PrefHelper.java From AndroidDemo with MIT License | 4 votes |
public static TableDataResponse getAllPrefData(Context context, String tag) { TableDataResponse response = new TableDataResponse(); response.isSuccessful = true; response.isSelectQuery = true; TableDataResponse.TableInfo keyInfo = new TableDataResponse.TableInfo(); keyInfo.isPrimary = true; keyInfo.title = "Key"; TableDataResponse.TableInfo valueInfo = new TableDataResponse.TableInfo(); valueInfo.isPrimary = false; valueInfo.title = "Value"; response.tableInfos = new ArrayList<>(); response.tableInfos.add(keyInfo); response.tableInfos.add(valueInfo); response.rows = new ArrayList<>(); SharedPreferences preferences = context.getSharedPreferences(tag, Context.MODE_PRIVATE); Map<String, ?> allEntries = preferences.getAll(); for (Map.Entry<String, ?> entry : allEntries.entrySet()) { List<TableDataResponse.ColumnData> row = new ArrayList<>(); TableDataResponse.ColumnData keyColumnData = new TableDataResponse.ColumnData(); keyColumnData.dataType = DataType.TEXT; keyColumnData.value = entry.getKey(); row.add(keyColumnData); TableDataResponse.ColumnData valueColumnData = new TableDataResponse.ColumnData(); valueColumnData.value = entry.getValue().toString(); if (entry.getValue() != null) { if (entry.getValue() instanceof String) { valueColumnData.dataType = DataType.TEXT; } else if (entry.getValue() instanceof Integer) { valueColumnData.dataType = DataType.INTEGER; } else if (entry.getValue() instanceof Long) { valueColumnData.dataType = DataType.LONG; } else if (entry.getValue() instanceof Float) { valueColumnData.dataType = DataType.FLOAT; } else if (entry.getValue() instanceof Boolean) { valueColumnData.dataType = DataType.BOOLEAN; } else if (entry.getValue() instanceof Set) { valueColumnData.dataType = DataType.STRING_SET; } } else { valueColumnData.dataType = DataType.TEXT; } row.add(valueColumnData); response.rows.add(row); } return response; }
Example 14
Source File: SPUtils.java From shinny-futures-android with GNU General Public License v3.0 | 4 votes |
/** * 返回所有的键值对 */ public static Map<String, ?> getAll(Context context) { SharedPreferences sp = context.getSharedPreferences(getSpName(context), Context.MODE_PRIVATE); return sp.getAll(); }
Example 15
Source File: SharedPreferencesUtil.java From landlord_client with Apache License 2.0 | 4 votes |
private static Map<String, ?> getAll(Context context) { SharedPreferences sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE); return sp.getAll(); }
Example 16
Source File: Pref.java From springreplugin with Apache License 2.0 | 4 votes |
public static Map<String, ?> ipcGetAll() { SharedPreferences x = Pref.getTempSharedPreferences(PREF_TEMP_FILE_PACM); Map<String, ?> a = x.getAll(); return a; }
Example 17
Source File: ActivitySettings.java From tracker-control-android with GNU General Public License v3.0 | 4 votes |
private void xmlExport(SharedPreferences prefs, XmlSerializer serializer) throws IOException { Map<String, ?> settings = prefs.getAll(); for (String key : settings.keySet()) { Object value = settings.get(key); if ("imported".equals(key)) continue; if (value instanceof Boolean) { serializer.startTag(null, "setting"); serializer.attribute(null, "key", key); serializer.attribute(null, "type", "boolean"); serializer.attribute(null, "value", value.toString()); serializer.endTag(null, "setting"); } else if (value instanceof Integer) { serializer.startTag(null, "setting"); serializer.attribute(null, "key", key); serializer.attribute(null, "type", "integer"); serializer.attribute(null, "value", value.toString()); serializer.endTag(null, "setting"); } else if (value instanceof String) { serializer.startTag(null, "setting"); serializer.attribute(null, "key", key); serializer.attribute(null, "type", "string"); serializer.attribute(null, "value", value.toString()); serializer.endTag(null, "setting"); } else if (value instanceof Set) { Set<String> set = (Set<String>) value; serializer.startTag(null, "setting"); serializer.attribute(null, "key", key); serializer.attribute(null, "type", "set"); serializer.attribute(null, "value", TextUtils.join("\n", set)); serializer.endTag(null, "setting"); } else Log.e(TAG, "Unknown key=" + key); } }
Example 18
Source File: SPUtil.java From Ency with Apache License 2.0 | 2 votes |
/** * 返回所有的键值对 * * @param context * @return */ public static Map<String, ?> getAll(Context context) { SharedPreferences sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE); return sp.getAll(); }
Example 19
Source File: SPUtils.java From MvpRxJavaRetrofitOkhttp with MIT License | 2 votes |
/** * 返回所有的键值对 * * @return */ public static Map<String, ?> getAll() { SharedPreferences sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE); return sp.getAll(); }
Example 20
Source File: SPUtil.java From FakeWeather with Apache License 2.0 | 2 votes |
/** * 返回所有的键值对 * * @param context * @return */ public static Map<String, ?> getAll(Context context) { SharedPreferences sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE); return sp.getAll(); }