So, I’m trying to store HashMap on Android. I think it’s better to use internal storage, but I don’t understand how to save HashMap in it and then read it later. Can someone explain how to do that properly, please?
There are counters with their own names and values. I want to load them onсe when some activity was started, work with them (change, delete, add new), and then save that data to use next time. Right now I use HashMap because it’s easy to delete/add values.
HashMap<String, Integer> counters;
SharedPreferences also store data in key-value pair as hashmap, so why not get all key-values from hashmap and store into map, as it:
To fetch values you can use:
http://developer.android.com/reference/android/content/SharedPreferences.html#getAll%28%29
use:
Code is not compiled, so it may have some minor errors, but should work.