I still have not wrapped my head around synchronization. I know it there, I know why it is used and what is behind it, but I lack practical skills and real examples to understand how it works and how it is implemented, when several actions try to read / write to the database at that same time. Do you share your objects through the application or is the system intelligent enough to synchronize various objects of the same type?
Perhaps the content provider is the best way, as I understand it, built into synchronization.
I'm distracted.
Im still confused about database activity. Remember that I have a service that runs every 60 seconds in the background, reading the same table that the update function writes to. Yes, I want to change this, but now I want to understand how to process databases in Android more and work out what happens.
If I have a loop, for example:
db = provider.getReadableDatabase();
while(theres_still_work_today) {
do_some_calculations;
update_database;
}
provider.close();
It works great as a standalone. If I try to put this on a stream, I get errors galore regarding blocking. But at startup:
while(theres_still_work_today) {
do_some_calculations;
db = provider.getReadableDatabase();
provider.close();
update_database;
}
I find it strange, it actually seems to be faster and does not give problems with blocking.
Am I really incredibly lucky that I am not getting two events that trigger a block at the same time? Is there some kind of timeout built into database processing in Android / SQLite?
, ?
Android. / , , .
.
, "isDatabaseLockedByOtherThreads()" , .
?