Reputation: 2684
I am using Marvel api to get name, images and description, but I want the users to view it in offline mode too...How can I cache it apart from db system? Can Lru cache be used to do it? I just want to know the approach
Upvotes: 1
Views: 299
Reputation: 45072
Store your marvel arrayList to db with the help of TinyDB in ACtivity onPause()
CallaBack
ArrayList<Person> usersWhoWon = new ArrayList<Person>();
tinydb.putListObject("allWinners", usersWhoWon);
and then in onResume()
callaback check if user is offline and fetch your marvel comic list from tinyDB
new TinyDB(getApplicationContext()).getListObject(
PreferenceHelper.MY_CART_LIST_LOCAL, Marvel.class)
Upvotes: 1