I have created a quite nice implementation of a Broadcast/BroadcastReceiver where I am pulling down information via a Service from a Web API, Broadcasting the result of the received data and then changing the UI when the OnReceive function is called in the Activity which updates the UI.
The way I am updating the UI though is by passing the 'id' of the row to the database and then pulling the data out again.
This doesn't seem very optimal as I have to access the database twice. Once to save and once to retrieve. How can I optimise this? How can I optimise the process of updating the UI without having to go to the database again?
Options which I have researched:
- Send a Parceable/Serializable object in the Intent when Broadcasting
- Saving the retrieved data in a static class and using that data when onReceive is called.
Thank you in advance.