I am trying to save my StringSet "purchasedAdvances" to the SharedPreferences of my app and noticed that it only gets written to the file, if I write another change to the file. Is this a bug or a feature anyone knows? Took me a while to figure this out...
so I am doing this in my OnSave():
for (String name: purchasedAdvances) {
Log.v("Button", "inSave: " + name);
}
savedCards = this.getActivity().getSharedPreferences(PURCHASED, Context.MODE_PRIVATE );
SharedPreferences.Editor editorCards = savedCards.edit();
editorCards.putInt("saved", purchasedAdvances.size());
editorCards.putStringSet(PURCHASED, purchasedAdvances);
editorCards.commit();
which works, but if I remove the line
editorCards.putInt("saved", purchasedAdvances.size());
because I do not need it, my Set does NOT get saved to the file and still has its old data. The Log lines above show me that there are new entries in the Set if I add any, but they do not end up in the pref file, which seems odd to me.
In the end, I can live with this, but still wondering if this is a bug or a feature or (which seems more likely) I am doing something terribly wrong and are not aware of it.