Code example for CursorLoader

0
    getSupportLoaderManager().initLoader(ContactsQuery.QUERY_ID, null, this);
  } 
 
  @Override public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    if (id == ContactsQuery.QUERY_ID) {
      return new CursorLoader(this, //
          ContactsQuery.CONTENT_URI, //
          ContactsQuery.PROJECTION, //
          ContactsQuery.SELECTION, //
          null, // 
          ContactsQuery.SORT_ORDER);
    } 
    return null; 
  } 
 
  @Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    adapter.swapCursor(data);
  } 
 
  @Override public void onLoaderReset(Loader<Cursor> loader) {
    adapter.swapCursor(null);