Hello :wave:, I was trying to save every title her...
# android
a
Hello 👋, I was trying to save every title here is my code . . . val title = edittext?.text OnClick . . . context.getSharedPreferences(TAG, Context.MODE_PRIVATE).let { It.edit().putStringSet(TAG, HashSet<String>().also{ It.add(title) }).apply() } . . . . . . It saves the title but it also replace the the old with newer(delete all values and add new values) for e.g my first title was foo When I add another title in edittext and save it Like "hello world" during retrieving it shows only [hello world] all I want was [foo, hello world]
g
you probably need to get the current values first, add the new one to the set and then call edit().putStringSet(..)
a
Sorry I forget the TAG. I have added in my project but I forget here @Gonçalo Palaio maybe see the edited one. I don't think 🤔 now the key was problem
g
in a simplified way you’re doing: putStringSet(TAG, [title]) I think what you want is: currentSet = getStringSet(TAG) currentSet.add(title) putStringSet(TAG, currentSet)
☝️ 1
a
Sorry for delay i was offline, Thanks it work
👍 1