android - SQLite database and CursorLoaders -


I am working on a client-side Android application that will retrieve data from a URL and save it to a local database. Could. I'm familiar with using the SQLiteDatabase for this operation.

My concern started when I was reading about SimpleCursorAdapter to display the table row in the list when I was about Cursor Loader If I read, to manage the cursor asynchronously

This is the thing that when they read about it, they talk about ContentProvider and As far as I know, that class is used to share data between apps Is done, so I got super confused.

Can you guide me through this, I do not know that I need to use a cursor loader because I do not know what it is, and it Sharing data between what to do and what to do with the ContentProvider .

EDIT: Reading the demo app found here

It seems that you want to retrieve the data line 122: On CrateLoader

  Public Loader & lt; Cursor & gt; OnCreateLoader (int loaderId, bundle args) {loader = new SQLiteCursorLoader (this, db, "SELECT _ID, title, value" + "with title ORDER", blank); Return (loader); }  

Does this mean that I can not use the SQLiteDatabase # query () method now? Such as db.query (table, column, selection, selection, group, group, having, order);

Content providers were first designed to share data on AIDS, but they were a SQLite database (Simple API, Controller and SyncEdapter integration, etc.) to provide great benefits.

This will help you understand the benefits of help to get the content provider you want:

As you know Because you are not going to do database queries (and usually I / O operations) on the database thread, a cursor loader can access the database in a background thread for you and distributes the result cursor on the UI thread. The cursor loader uses the ContentResolver interface to use your ContentProvider implementation that will execute your query and the cursor will return.


Comments