我创建了一个Activity实现LoaderManager.LoaderCallbacks<Cursor>接口的简单方法 .该OnCreateLoader()很简单:
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args)
{
Log.d(TAG, "On create loader");
Uri queryUri = ContentUris.withAppendedId(SmartPresentationMessage.Person.CONTENT_URI, 1);
CursorLoader cursorLoader = new CursorLoader(this, queryUri, null, null, null, null);
return cursorLoader;
}
Run Code Online (Sandbox Code Playgroud)
当我getLoaderManager().initLoader(0, null, this)在Activity创建时调用时调用此方法.
我的问题是在我的ContentProvider,有以下query()方法:
@Override
public Cursor query(Uri uri, String[] projection, String where,
String[] whereArgs, String sortOrder)
{
int match = sUriMatcher.match(uri);
Cursor queryCursor;
SQLiteDatabase mdb = mOpenHelper.getReadableDatabase();
switch (match)
{
case PERSON:
long …Run Code Online (Sandbox Code Playgroud)