I have a SQLite database I would like to query. I want to target Android 2.2 through ICS. I came across this article on how to do this, but it uses deprecated code (does not query asynchronously, but on the UI thread). I've since read that I can use CursorLoader
along with LoaderManager
to do this task the preferred, best practices way (as to not bog down the UI thread).
The problem is finding a concise example to explain to me how to do this. 1) Load the database, 2) query it, 3) use the result to populate an AutoCompletetextBox list view.
Does such an example exist?
A CursorLoader is a specialized member of Android's loader framework specifically designed to handle cursors. In a typical implementation, a CursorLoader uses a ContentProvider to run a query against a database, then returns the cursor produced from the ContentProvider back to an activity or fragment.
This class was deprecated in API level 28.
I know this is an old question but for people who visit this page:
SimpleCursorAdapter has a new constructor:
SimpleCursorAdapter(Context context, int layout, Cursor c, String[] from, int[] to, int flags)
this cunstructor does not use UI thread. You can use it safey.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With