gruszczy
gruszczy

Reputation: 42208

Constructing LoaderManager for SQLite Database in Android

I am following this example: http://developer.android.com/guide/topics/ui/layout/listview.html

I am at this method:

// Called when a new Loader needs to be created
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    // Now create and return a CursorLoader that will take care of
    // creating a Cursor for the data being displayed.
    return new CursorLoader(this, ContactsContract.Data.CONTENT_URI,
            PROJECTION, SELECTION, null, null);
}

I am trying to construct my own CursorLoader for a SQLite database. I have created earlier a subclass of SQLiteOpenHelper. How do I get a URI to be used as a second argument of CursorLoader constructor?

Upvotes: 1

Views: 3007

Answers (1)

rubenlop88
rubenlop88

Reputation: 4221

If you want to use a CursorLoader to load data from your own SQLite database, then you must implement a ContentProvider first. There are many good tutorials out there, form example Writing your own Content Provider from Wolfram Rittmeyer's blog.

The URI in the example is from the ContactsProvider.

Upvotes: 1

Related Questions