Skip to content Skip to sidebar Skip to footer

Clear Data From Cache Using Greendao

In my app, there are 4 Activities starting from activities 1 to 4. Database creation takes place in activity1 and values are updated in activities 2, activities 3 etc.But when i m

Solution 1:

You can do it with 2 approaches.

1. startActivityForResult() approach

Follow the following steps. If confused, you may check this tutorial.

  1. start your 2nd Activity using startActivityForResult()
  2. Override the onActivityResult() in the 1st Activity. There, clear the DB cache and refetch the data.
  3. before finish() call in 2nd Activity, call setResult().

2. onResume() approach

  • clear the DB cache and load the data in onResume().

  • This way every time the Activity shows up, data will be fetched. It's not efficient because every time your Activity comes to foreground, onResume() is called.

Solution 2:

Simple Solution is

1:Just moves from one next activity to the previous activity using Intent(Not through finish() )

It clears old cache and loads the updated value..

Hope this helps somebody.. :)

Post a Comment for "Clear Data From Cache Using Greendao"