I found out that some values had been stored to Set
got lost after restarting the application. Why? Is this an Android API bug? Somebody advised to store strings in a database. I haven't tested it yet, but I think this advice is a solution of the problem. What about getStringSet
and putStringSet
?
From my understanding, it's a bug. The problem is when you try to store a set, Android compares the modified set that you are trying to save with the current one stored in the SharedPreferences. And when they are the same object (having the same reference), the new one is ignored.
A work around is to create a new copy of the set before storing it.
Here is the details and the issue is submitted at https://code.google.com/p/android/issues/detail?id=27801.
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