Reputation: 60691
Can a SharedPreferences.Editor
be safely reused? In other words, can I have this declared once in my class:
val editor = prefs.edit()
and then use its apply()
method multiple times, like this?
editor.putString("myString", "Some string").apply()
// some time later...
editor.putInt("myInt", 682).apply()
Upvotes: 3
Views: 231
Reputation: 126523
Yes you can reuse it and then use its apply()
method multiple times to save the values.
I see that you are using Kotlin, is the same as in Java/Android SDK.
Upvotes: 3