Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Save all values include default values declared in KotprefModel
.forEach { property ->
property.isAccessible = true
(property.getDelegate(SomePref) as? AbstractPref<Any>)?.let {
it.setToPreference(property, property.get(SomePref)!!, SomePref.preferences)
println("save preference ${} -> ${property.get(SomePref)}")
(property.getDelegate(SomePref) as? AbstractStringSetPref)?.let {
getSharedPreferences(SomePref.kotprefName, Context.MODE_PRIVATE)
.putStringSet(it.preferenceKey, property.get(SomePref) as MutableSet<String>)
println("save preference ${} -> ${property.get(SomePref)}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment