I have an activity with 3 fragments and I need to update fragExchangeHistory listView from DB when I add an object to database in fragCurrencyExchange. How could I do it?
Code: GitHub
Use an EventBus
like https://github.com/greenrobot/EventBus to communicate between fragments and other components. So when Fragment A update something in the database, you can fire an event to inform the other fragments about the changes.
Implement an Observer pattern between the activity and the fragments so you can notify when you add some new data up to the activity and from activity to fragments. In this way the notification flow is:
As you can see this couples quite a while your activity with the fragments so I usually use some kind of Event bus library like this or this that makes your code quite decoupled and easy to understand.
Maybe you should use CursorLoader
.A CursorLoader automatically re-runs the query when data associated with the query changes.
You should check this from the Android Developer official site.