Issue
I need to cache an object to access it every and each Activity and Fragment in my app.
I tried to make it static, But , unfortunately, sometimes Android OS makes this static as null which crashes my app with no reason.
so is it a good practice to use SharedPreferences with Gson to serialize and
cache the object on the disk?
Solution
Generaly, you shouldn't use too much the SharedPreferences as it's not as fast as a local database, but actually, you can use it if your set of data is not too big and if you just want a simple cache.
A simple alternative would be to use Realm.
Answered By - Hugo Gresse
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.