Reputation: 319
I would like to share with you one problem that I am facing developing one Android application.
The architecture of my application is the following:
The problem arrives when I open the application I load all the info in the databse by means of loaders. In the mean time I create a service to obtain all the new information. As the back end don't save a time value for modifications or something like that in the items, I have to delete all the database items and insert the new ones.
In that time the user can click on the item loaded from the data base, but if just in that moment the item open in the detail activity (from the data in the data base) could cause a null pointer due to the item is not in the database in that moment until the new items are loaded.
My question is, how could I solve the problem? I would like to hear some architecture that could be better in that case. Could you provide some link with documentation or information?
Thank you in advance!
Upvotes: 0
Views: 30
Reputation: 9473
Learn about transactions. Do your delete/insert inside of a transaction, and make sure you understand about transaction isolation. If you do your delete/insert in a transaction, then the other connection should not know of the data until the transaction is committed.
Upvotes: 1