Android 从特定的SharedPreferences文件中检索所有存储的条目
示例
该getAll()方法从首选项中检索所有值。例如,我们可以使用它来记录的当前内容SharedPreferences:
private static final String PREFS_FILE = "MyPrefs";
public static void logSharedPreferences(final Context context) {
SharedPreferences sharedPreferences = context.getSharedPreferences(PREFS_FILE, Context.MODE_PRIVATE);
Map<String, ?> allEntries = sharedPreferences.getAll();
for (Map.Entry<String, ?> entry : allEntries.entrySet()) {
final String key = entry.getKey();
final Object value = entry.getValue();
Log.d("map values", key + ": " + value);
}
}该文档警告您有关修改Collection返回者getAll:
请注意,您不得修改此方法返回的集合,也不得更改其任何内容。如果这样做,则不能保证所存储数据的一致性。
热门推荐
10 朋友新年祝福语大全 简短
11 新年祝福语简短大方兔年
12 搬新家礼物祝福语简短
13 同学见面花束祝福语简短
14 五一假期祝福语幽默简短
15 离职欢送敬酒祝福语简短
16 对学弟的祝福语简短
17 考老师辞职祝福语简短
18 祝福语驱散霉运的话简短