How to get all keys in SharedPreferences
, not the value of the preference just key only?
prefA = getSharedPreferences("MyAttack", MODE_PRIVATE); prefB= getSharedPreferences("MySkill", MODE_PRIVATE);
SharedPreferences
has the method getAll()
that returns a Map<String, ?>
. From the Map you can retrieve easily the keys with keySet()
and the key/value mappings with entrySet()
:
Map<String, ?> allEntries = prefA.getAll(); for (Map.Entry<String, ?> entry : allEntries.entrySet()) { Log.d("map values", entry.getKey() + ": " + entry.getValue().toString()); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With