It must be stupid question, but I'm really new to Kotlin and I didn't find any solution.
How to declare class field? Like we can have it in java:
protected SharedPreferences mSharedPreferences;
And later in onCreate()
:
mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
Now I can use it anywhere I want (in subclasses of this base activity).
I try to do same in Kotlin:
protected var sharedPreferences : SharedPreferences
And in onCreate()
:
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
But I get a warning: "Property must be initialized or be abstract"