if there any one who can read this article and sug...
# android
z
if there any one who can read this article and suggest me is this the best approach to implement this https://medium.com/@skydoves/how-to-manage-sharedpreferences-on-android-project-5e6d5e28fee6
g
Please, do not cross-post your messages to different channels
☝️ 1
z
yes sure i am new user sorry for the inconvenience
l
I'd advertise my solution that is simpler: https://github.com/LouisCAD/Splitties/blob/master/preferences/README.md It solves the type safety and key safety problems the vanilla approach may have.
👍 1
g
Nice, we use similar approach on one of our projects, but not so generic implementation
but in our implementation we override delegate for standard preferences class, so it works like
var magicNumber: Int by somePreferencesInstance
(if default value is not required)
l
I prefer to hide the underlying risky API as much as possible, that's why I went for a wrapper
p
What do you think about my solution posted in #general ?
g
we use it only for implementation of preferences class, so it will not be visble from outer API and real implementation that requires passing preferences is not available for any code, only to DI. Also this solves problem with multiple instances (just inject Singleton instance)
l
@Paul Woitaschek I think it's good because it's type and key safe, but maybe too tied to Rx (which is great when you use Rx!). I prefer what I did in Splitties (posted above) because its just properties (which can't be simpler I think), and you can implement custom logic and make the delegated properties private if needed, so you can have anything you want, backed by type and key safe shared preferences.