-1

I have a recyclerView on first Activity(reads data from DB) and insert data on it from second activity(Insert data into DB). Now I want to update that recyclerView when Back buttonPressed on second Activity(when back from second activity to first activity) now what should I do?

Anas Mehar
  • 2,390
  • 9
  • 19

1 Answers1

2

Use LiveData and Room. Whenever room database updates, it'll give trigger onChanged to LiveData. Hence, If your activity is observing the room database. You can simply call adapter.notifyDataSetChanged() inside the observer.

Sandesh Baliga
  • 427
  • 4
  • 16