I want to use this library to replace SharedPrefer...
# multiplatform
h
I want to use this library to replace SharedPreferences in Multiplatform project. I want to store token from Firebase. Firebase needs you to create a service in Android side which you can’t put in commonMain. How can I access Settings from a service in androidApp? https://github.com/russhwolf/multiplatform-settings
r
You could add the library to your app-level dependencies if you want to talk to the
Settings
interface from there. Or you could just talk to
SharedPreferences
, and if you use the same
SharedPreferences
instance to create your
AndroidSettings
then the data in them will be the same.
❤️ 1
h
by same instance do you mean shared preferences with same key? and thank you very much for amazing library 🙂
r
I mean if you have a
val preferences: SharedPreferences
and do
val settings = AndroidSettings(preferences)
, then
preferences.getString("key", "default")
will be the same as
settings.getString("key", "default")
h
@russhwolf I use no arg version of the library in commonModule will this make a difference?
r
If you’re using no-arg then it’s the equivalent of
PreferenceManager.getDefaultSharedPreferences(context)
😌 1
h
thank you very much again @russhwolf