I'm trying to store the Checkbox text and it's state which is a boolean inside a Shared Preference. I'm having the issue - Incompatible types Entry<String, Capture<?>>
found Entry<String, java.lang.Boolean>
required when retrieving the value (at this line Map.Entry<String, Boolean> entry4
)
This is how I'm storing the values inside shared preferences -
SharedPreferences checkedFilterPref = getContext().getSharedPreferences(
Constants.FILTER_CHECKED_PREF, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = checkedFilterPref.edit();
for (Map.Entry<String, Boolean> entry1 : filterPrefHashMap.entrySet()) {
editor.putBoolean(entry1.getKey(), entry1.getValue());
}
editor.commit();
This is how I'm trying to retrieve the HashMap values -
for (Map.Entry<String, Boolean> entry4 : checkedFilterPref.getAll().entrySet()) {
filterPrefHashMap.put(entry4.getKey(), entry4.getValue());
}
I'm following the technique shared in this StackOverflow post. I can't seem to get it right. Any help can be appreciated.