I’ve written a content provider with one database helper and have started to build a “manager” class to perform specific inserts, deletes, updates, queries etc.
The manager returns cursorloaders for my cursoradapters where necessary which I believe a multi-threaded.
My question is, when I perform actions on the db that do not involve a loader should I create a new thread?
An example might be, that I perform a save from the action bar – should I multi thread the insert manually? That goes for updates queries deletes etc also?
You have to be pretty cautious when multi-threading database actions.
Is there a need to multithread? Unless your database is very large and the actions that you are performing are very heavy on the database then I would say there isn’t a need.
Is it safe? If the threads are performing actions on the same tables then you have to be extremely cautious when running multiple threads. You have to make sure that you control which thread runs first and the impact that the thread has on the database. Generally, this is unwise.
From the sound of your specific problem, I would say that multiple threads are not necessary. Perhaps you could look into a background thread if this is impacting the user and you want them to wait the least amount of time as possible!