Techierj Techierj - 8 months ago 63
Android Question

What is the best pattern to sync data between two recycler view with two activities?

i have two activities where they have almost same data,i am using same Adapter, But the problem is how to sync data...

Activity A has recyclerview where it has like buttons in each row with unique id.
Activity B also have same recyclerview but with some filter mechanism so it is not going to show all row, my question is how to handle like button state in Activity A and Activity B, such that if i click on activity B's like button than activity A's like button will automatically gets checked and vise versa.

Thanks in adv. for your help... happy coding :)


You should use common data source for both the recycler views.

  1. Get data from API
  2. Save data in your local db
  3. Feed the data to your Activity A recycler view
  4. Feed the same data to your Activity B recycler view
  5. All the changes you make to data should be in local db so both the views can update automatically.