Is it necessary to access an SQLiteDatabase in an AsyncTask?

android, android-asynctask, android-sqlite

Solution

It is recommended to not perform IO from your main application thread, but, it does not have to be done using an `AsyncTask`.

You have other options for getting out of your main thread too, some of which include the Loader Framework, IntentService, and Executors.

Problem

Is it necessary or even good practice to always access an SQLiteDatabase from an AsyncTask? Doing it from the UI thread seems to cause no problems and is much simpler to implement.

Original source