I have an Android app with SQL Lite database. I want to access it in background thread to populate listView
.
What should I use: AsycnTask
, Thread
or Service
?
I have an Android app with SQL Lite database. I want to access it in background thread to populate listView
.
What should I use: AsycnTask
, Thread
or Service
?
Best combination would be, ListFragment, Sqlite (with or without content provider), CursorLoader, CursorAdapter, Service.
Most of time I prefer to use Loaders here are some sample Example Loader and LoaderManager with Cursor and tutorial Android Design Patterns : Why Loaders.
Loader characteristics
- They are available to every Activity and Fragment.
- They provide asynchronous loading of data.
- They monitor the source of their data and deliver new results when the content changes.
- They automatically reconnect to the last loader's cursor when being recreated after a configuration change. Thus, they don't need to re-query their data.