You should not do any time-consuming task on the main thread (UI thread), like any network operation, file I/O, or SQLite database operations. So for this kind of operation, you should create a worker thread, but the problem is that you can not directly perform any UI related operation from your worker thread. For that, you have to use Handler
and pass the Message
.
To simplify all these things, Android provides various ways, like AsyncTask
, AsyncTaskLoader
, CursorLoader
or IntentService
. So you can use any of these according to your requirements.