How do you use SharedPreferences in a non-Activity class? I tried making a generic Preferences utility class and importing android.content.Context but Eclipse s
android.content.Context
In Kotlin you can do this:
val myClass = MyClass(this)
Now this is how you can get context in class
class MyClass(context: Context) { val context: Context = context }
Now to get Shared Preferences with context you can do this:
context.getSharedPreferences(...)