loading...

re: Kotpref: Easy SharedPreferences library for Kotlin android VIEW POST

FULL DISCUSSION
 

This is interesting. Can you specify the SharedPreferences file to use for particular KotprefModel? For example, a unique file for user settings and a unique file for onboarding state tracking?

 

Thank you!

By default, file name is same as class name. But you can change it by overriding kotprefName
property.
If file name is fixed, just override it.

object Sample : KotprefModel() {
    override val kotprefName: String = "specific_name"
}

If name is dynamic, declare KotprefModel class with constructor parameter to init this property.

class Sample(override val kotprefName: String) : KotprefModel()
Code of Conduct Report abuse