mercredi 6 avril 2016

Android SQLite operations queue

Ok, it was asked many times, but I still cannot find correct way to solve this.

I have SQLite database and different operations with it in multiple threads.
How can I avoid locking problem, if I want operations from different thread (write, delete, read) be executed one-by-one?

One way, I suppose, is to create one synchronized method in my DBAdapter, which will handle all calls. I don't like it, cause it should accept all possible params, it would be giant.

Second is to create IntentService and to address all calls to it. Possibly good, but there is a problem with transferring result (Cursor, for example) back to calling Activity.

I don't see other options at the moment. Any help greatly appreciated!

Aucun commentaire:

Enregistrer un commentaire