Do I need to access the SQLiteDatabase in AsyncTask?

Is it necessary or even good practice to always access SQLiteDatabase from AsyncTask?

Running this from the user interface thread does not seem to cause problems and is much easier to implement.

+6
source share
3 answers

It is recommended that you do not perform I / O from the main application thread, but do not >

You have other options for exiting the main thread, some of which include the Loader Framework , IntentService, and Artists .

+4
source

This is a good practice. Database operations are not always fast, so Android recommends that you perform all database and network operations in the background thread (AsyncTask, Runnable, etc.).

+4
source

No, it is NOT necessary to ALWAYS access your database in another thread. It depends on how long it takes. Usually reading / writing is fast, do not slow down the user interface and do not require another thread. However, when performing lengthy operations, such as cleaning, etc., Then yes, it is a good idea to do them in another thread.

+3
source

All Articles