Java Code Examples for android.database.Cursor#unregisterContentObserver()
The following examples show how to use
android.database.Cursor#unregisterContentObserver() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CursorAdapter.java From adt-leanback-support with Apache License 2.0 | 6 votes |
/** * Swap in a new Cursor, returning the old Cursor. Unlike * {@link #changeCursor(Cursor)}, the returned old Cursor is <em>not</em> * closed. * * @param newCursor The new cursor to be used. * @return Returns the previously set Cursor, or null if there wasa not one. * If the given new Cursor is the same instance is the previously set * Cursor, null is also returned. */ public Cursor swapCursor(Cursor newCursor) { if (newCursor == mCursor) { return null; } Cursor oldCursor = mCursor; if (oldCursor != null) { if (mChangeObserver != null) oldCursor.unregisterContentObserver(mChangeObserver); if (mDataSetObserver != null) oldCursor.unregisterDataSetObserver(mDataSetObserver); } mCursor = newCursor; if (newCursor != null) { if (mChangeObserver != null) newCursor.registerContentObserver(mChangeObserver); if (mDataSetObserver != null) newCursor.registerDataSetObserver(mDataSetObserver); mRowIDColumn = newCursor.getColumnIndexOrThrow("_id"); mDataValid = true; // notify the observers about the new cursor notifyDataSetChanged(); } else { mRowIDColumn = -1; mDataValid = false; // notify the observers about the lack of a data set notifyDataSetInvalidated(); } return oldCursor; }
Example 2
Source File: CursorAdapter.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
/** * Swap in a new Cursor, returning the old Cursor. Unlike * {@link #changeCursor(Cursor)}, the returned old Cursor is <em>not</em> * closed. * * @param newCursor The new cursor to be used. * @return Returns the previously set Cursor, or null if there wasa not one. * If the given new Cursor is the same instance is the previously set * Cursor, null is also returned. */ public Cursor swapCursor(Cursor newCursor) { if (newCursor == mCursor) { return null; } Cursor oldCursor = mCursor; if (oldCursor != null) { if (mChangeObserver != null) oldCursor.unregisterContentObserver(mChangeObserver); if (mDataSetObserver != null) oldCursor.unregisterDataSetObserver(mDataSetObserver); } mCursor = newCursor; if (newCursor != null) { if (mChangeObserver != null) newCursor.registerContentObserver(mChangeObserver); if (mDataSetObserver != null) newCursor.registerDataSetObserver(mDataSetObserver); mRowIDColumn = newCursor.getColumnIndexOrThrow("_id"); mDataValid = true; // notify the observers about the new cursor notifyDataSetChanged(); } else { mRowIDColumn = -1; mDataValid = false; // notify the observers about the lack of a data set notifyDataSetInvalidated(); } return oldCursor; }
Example 3
Source File: CursorAdapter.java From android-recipes-app with Apache License 2.0 | 6 votes |
/** * Swap in a new Cursor, returning the old Cursor. Unlike * {@link #changeCursor(Cursor)}, the returned old Cursor is <em>not</em> * closed. * * @param newCursor The new cursor to be used. * @return Returns the previously set Cursor, or null if there wasa not one. * If the given new Cursor is the same instance is the previously set * Cursor, null is also returned. */ public Cursor swapCursor(Cursor newCursor) { if (newCursor == mCursor) { return null; } Cursor oldCursor = mCursor; if (oldCursor != null) { if (mChangeObserver != null) oldCursor.unregisterContentObserver(mChangeObserver); if (mDataSetObserver != null) oldCursor.unregisterDataSetObserver(mDataSetObserver); } mCursor = newCursor; if (newCursor != null) { if (mChangeObserver != null) newCursor.registerContentObserver(mChangeObserver); if (mDataSetObserver != null) newCursor.registerDataSetObserver(mDataSetObserver); mRowIDColumn = newCursor.getColumnIndexOrThrow("_id"); mDataValid = true; // notify the observers about the new cursor notifyDataSetChanged(); } else { mRowIDColumn = -1; mDataValid = false; // notify the observers about the lack of a data set notifyDataSetInvalidated(); } return oldCursor; }
Example 4
Source File: BaseAbstractRecycleCursorAdapter.java From AppCodeArchitecture with Apache License 2.0 | 6 votes |
/** * Swap in a new Cursor, returning the old Cursor. Unlike * {@link #changeCursor(android.database.Cursor)}, the returned old Cursor is <em>not</em> * closed. * * @param newCursor The new cursor to be used. * @return Returns the previously set Cursor, or null if there wasa not one. * If the given new Cursor is the same instance is the previously set * Cursor, null is also returned. */ public Cursor swapCursor(Cursor newCursor) { if (newCursor == mCursor) { return null; } Cursor oldCursor = mCursor; if (oldCursor != null) { if (mChangeObserver != null) oldCursor.unregisterContentObserver(mChangeObserver); if (mDataSetObserver != null) oldCursor.unregisterDataSetObserver(mDataSetObserver); } mCursor = newCursor; if (newCursor != null) { if (mChangeObserver != null) newCursor.registerContentObserver(mChangeObserver); if (mDataSetObserver != null) newCursor.registerDataSetObserver(mDataSetObserver); mRowIDColumn = newCursor.getColumnIndexOrThrow("_id"); mDataValid = true; // notify the observers about the new cursor notifyDataSetChanged(); } else { mRowIDColumn = -1; mDataValid = false; // notify the observers about the lack of a data set notifyDataSetChanged(); } return oldCursor; }
Example 5
Source File: CursorAdapter.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
/** * Swap in a new Cursor, returning the old Cursor. Unlike * {@link #changeCursor(Cursor)}, the returned old Cursor is <em>not</em> * closed. * * @param newCursor The new cursor to be used. * @return Returns the previously set Cursor, or null if there was not one. * If the given new Cursor is the same instance is the previously set * Cursor, null is also returned. */ public Cursor swapCursor(Cursor newCursor) { if (newCursor == mCursor) { return null; } Cursor oldCursor = mCursor; if (oldCursor != null) { if (mChangeObserver != null) oldCursor.unregisterContentObserver(mChangeObserver); if (mDataSetObserver != null) oldCursor.unregisterDataSetObserver(mDataSetObserver); } mCursor = newCursor; if (newCursor != null) { if (mChangeObserver != null) newCursor.registerContentObserver(mChangeObserver); if (mDataSetObserver != null) newCursor.registerDataSetObserver(mDataSetObserver); mRowIDColumn = newCursor.getColumnIndexOrThrow("_id"); mDataValid = true; // notify the observers about the new cursor notifyDataSetChanged(); } else { mRowIDColumn = -1; mDataValid = false; // notify the observers about the lack of a data set notifyDataSetInvalidated(); } return oldCursor; }
Example 6
Source File: CursorAdapter.java From guideshow with MIT License | 6 votes |
/** * Swap in a new Cursor, returning the old Cursor. Unlike * {@link #changeCursor(Cursor)}, the returned old Cursor is <em>not</em> * closed. * * @param newCursor The new cursor to be used. * @return Returns the previously set Cursor, or null if there wasa not one. * If the given new Cursor is the same instance is the previously set * Cursor, null is also returned. */ public Cursor swapCursor(Cursor newCursor) { if (newCursor == mCursor) { return null; } Cursor oldCursor = mCursor; if (oldCursor != null) { if (mChangeObserver != null) oldCursor.unregisterContentObserver(mChangeObserver); if (mDataSetObserver != null) oldCursor.unregisterDataSetObserver(mDataSetObserver); } mCursor = newCursor; if (newCursor != null) { if (mChangeObserver != null) newCursor.registerContentObserver(mChangeObserver); if (mDataSetObserver != null) newCursor.registerDataSetObserver(mDataSetObserver); mRowIDColumn = newCursor.getColumnIndexOrThrow("_id"); mDataValid = true; // notify the observers about the new cursor notifyDataSetChanged(); } else { mRowIDColumn = -1; mDataValid = false; // notify the observers about the lack of a data set notifyDataSetInvalidated(); } return oldCursor; }
Example 7
Source File: CircularViewCursorAdapter.java From CircularView with Apache License 2.0 | 6 votes |
/** * Swap in a new Cursor, returning the old Cursor. Unlike * {@link #changeCursor(Cursor)}, the returned old Cursor is <em>not</em> * closed. * * @param newCursor The new cursor to be used. * @return Returns the previously set Cursor, or null if there was not one. * If the given new Cursor is the same instance is the previously set * Cursor, null is also returned. */ public Cursor swapCursor(Cursor newCursor) { if (newCursor == mCursor) { return null; } Cursor oldCursor = mCursor; if (oldCursor != null) { if (mChangeObserver != null) oldCursor.unregisterContentObserver(mChangeObserver); if (mDataSetObserver != null) oldCursor.unregisterDataSetObserver(mDataSetObserver); } mCursor = newCursor; if (newCursor != null) { if (mChangeObserver != null) newCursor.registerContentObserver(mChangeObserver); if (mDataSetObserver != null) newCursor.registerDataSetObserver(mDataSetObserver); mRowIDColumn = newCursor.getColumnIndexOrThrow("_id"); mDataValid = true; // notify the observers about the new cursor notifyDataSetChanged(); } else { mRowIDColumn = -1; mDataValid = false; // notify the observers about the lack of a data set notifyDataSetInvalidated(); } return oldCursor; }
Example 8
Source File: CursorAdapter.java From V.FlyoutTest with MIT License | 6 votes |
/** * Swap in a new Cursor, returning the old Cursor. Unlike * {@link #changeCursor(Cursor)}, the returned old Cursor is <em>not</em> * closed. * * @param newCursor The new cursor to be used. * @return Returns the previously set Cursor, or null if there wasa not one. * If the given new Cursor is the same instance is the previously set * Cursor, null is also returned. */ public Cursor swapCursor(Cursor newCursor) { if (newCursor == mCursor) { return null; } Cursor oldCursor = mCursor; if (oldCursor != null) { if (mChangeObserver != null) oldCursor.unregisterContentObserver(mChangeObserver); if (mDataSetObserver != null) oldCursor.unregisterDataSetObserver(mDataSetObserver); } mCursor = newCursor; if (newCursor != null) { if (mChangeObserver != null) newCursor.registerContentObserver(mChangeObserver); if (mDataSetObserver != null) newCursor.registerDataSetObserver(mDataSetObserver); mRowIDColumn = newCursor.getColumnIndexOrThrow("_id"); mDataValid = true; // notify the observers about the new cursor notifyDataSetChanged(); } else { mRowIDColumn = -1; mDataValid = false; // notify the observers about the lack of a data set notifyDataSetInvalidated(); } return oldCursor; }
Example 9
Source File: RecyclerViewCursorBaseAdapter.java From HightCopyWX with Apache License 2.0 | 5 votes |
/** * Swap in a new Cursor, returning the old Cursor. Unlike * {@link #changeCursor(Cursor)}, the returned old Cursor is <em>not</em> * closed. * * @param newCursor The new cursor to be used. * @return Returns the previously set Cursor, or null if there wasa not one. * If the given new Cursor is the same instance is the previously set * Cursor, null is also returned. */ public Cursor swapCursor(Cursor newCursor) { if (newCursor == mCursor) { return null; } Cursor oldCursor = mCursor; if (oldCursor != null) { if (mChangeObserver != null) oldCursor.unregisterContentObserver(mChangeObserver); if (mDataSetObserver != null) oldCursor.unregisterDataSetObserver(mDataSetObserver); } mCursor = newCursor; if (newCursor != null) { if (mChangeObserver != null) newCursor.registerContentObserver(mChangeObserver); if (mDataSetObserver != null) newCursor.registerDataSetObserver(mDataSetObserver); mRowIDColumn = newCursor.getColumnIndexOrThrow("_id"); mDataValid = true; // notify the observers about the new cursor notifyDataSetChanged(); } else { mRowIDColumn = -1; mDataValid = false; // notify the observers about the lack of a data set // notifyDataSetInvalidated(); //there is no notifyDataSetInvalidated method we should use notifyDataSetChanged method; notifyDataSetChanged(); } return oldCursor; }
Example 10
Source File: CursorRecyclerAdapter.java From yahnac with Apache License 2.0 | 5 votes |
/** * Swap in a new Cursor, returning the old Cursor. Unlike * {@link #changeCursor(Cursor)}, the returned old Cursor is <em>not</em> * closed. * * @param newCursor The new cursor to be used. * @return Returns the previously set Cursor, or null if there wasa not one. * If the given new Cursor is the same instance is the previously set * Cursor, null is also returned. */ public Cursor swapCursor(Cursor newCursor) { if (newCursor == mCursor) { return null; } Cursor oldCursor = mCursor; if (oldCursor != null) { if (mChangeObserver != null) { oldCursor.unregisterContentObserver(mChangeObserver); } if (mDataSetObserver != null) { oldCursor.unregisterDataSetObserver(mDataSetObserver); } } mCursor = newCursor; if (newCursor != null) { if (mChangeObserver != null) { newCursor.registerContentObserver(mChangeObserver); } if (mDataSetObserver != null) { newCursor.registerDataSetObserver(mDataSetObserver); } mRowIDColumn = newCursor.getColumnIndexOrThrow("_id"); mDataValid = true; // notify the observers about the new cursor notifyDataSetChanged(); } else { mRowIDColumn = -1; mDataValid = false; // notify the observers about the lack of a data set // notifyDataSetInvalidated(); notifyItemRangeRemoved(0, getItemCount()); } return oldCursor; }
Example 11
Source File: CursorRecyclerAdapter.java From Ouroboros with GNU General Public License v3.0 | 5 votes |
/** * Swap in a new Cursor, returning the old Cursor. Unlike * {@link #changeCursor(Cursor)}, the returned old Cursor is <em>not</em> * closed. * * @param newCursor The new cursor to be used. * @return Returns the previously set Cursor, or null if there wasa not one. * If the given new Cursor is the same instance is the previously set * Cursor, null is also returned. */ public Cursor swapCursor(Cursor newCursor) { if (newCursor == mCursor) { return null; } Cursor oldCursor = mCursor; if (oldCursor != null) { if (mChangeObserver != null) oldCursor.unregisterContentObserver(mChangeObserver); if (mDataSetObserver != null) oldCursor.unregisterDataSetObserver(mDataSetObserver); } mCursor = newCursor; if (newCursor != null) { if (mChangeObserver != null) newCursor.registerContentObserver(mChangeObserver); if (mDataSetObserver != null) newCursor.registerDataSetObserver(mDataSetObserver); mRowIDColumn = newCursor.getColumnIndexOrThrow("_id"); mDataValid = true; // notify the observers about the new cursor notifyDataSetChanged(); } else { mRowIDColumn = -1; mDataValid = false; // notify the observers about the lack of a data set // notifyDataSetInvalidated(); notifyItemRangeRemoved(0, getItemCount()); } return oldCursor; }
Example 12
Source File: CursorAdapter.java From ExRecyclerViewLibrary with Apache License 2.0 | 5 votes |
/** * Swap in a new Cursor, returning the old Cursor. Unlike * {@link #changeCursor(Cursor)}, the returned old Cursor is <em>not</em> * closed. * * @param newCursor The new cursor to be used. * @return Returns the previously set Cursor, or null if there wasa not one. * If the given new Cursor is the same instance is the previously set * Cursor, null is also returned. */ public Cursor swapCursor(Cursor newCursor) { if (newCursor == mCursor) { return null; } Cursor oldCursor = mCursor; if (oldCursor != null) { if (mChangeObserver != null) oldCursor.unregisterContentObserver(mChangeObserver); if (mDataSetObserver != null) oldCursor.unregisterDataSetObserver(mDataSetObserver); } mCursor = newCursor; if (newCursor != null) { if (mChangeObserver != null) newCursor.registerContentObserver(mChangeObserver); if (mDataSetObserver != null) newCursor.registerDataSetObserver(mDataSetObserver); mRowIDColumn = newCursor.getColumnIndexOrThrow("_id"); mDataValid = true; // notify the observers about the new cursor notifyDataSetChanged(); } else { mRowIDColumn = -1; mDataValid = false; // notify the observers about the lack of a data set notifyDataSetChanged(); // notifyDataSetInvalidated(); } return oldCursor; }
Example 13
Source File: MediaStoreCursorRecyclerAdapter.java From libcommon with Apache License 2.0 | 5 votes |
/** * カーソルを交換 * @param newCursor * @return */ @Nullable protected Cursor swapCursor(@Nullable final Cursor newCursor) { if (DEBUG) Log.v(TAG, "swapCursor:" + newCursor); if (newCursor == mCursor) { return null; } Cursor oldCursor = mCursor; if (oldCursor != null) { if (mChangeObserver != null) { oldCursor.unregisterContentObserver(mChangeObserver); } if (mDataSetObserver != null) { oldCursor.unregisterDataSetObserver(mDataSetObserver); } } synchronized (mSync) { mCursor = newCursor; } if (newCursor != null) { if (mChangeObserver != null) { newCursor.registerContentObserver(mChangeObserver); } if (mDataSetObserver != null) { newCursor.registerDataSetObserver(mDataSetObserver); } mDataValid = true; // notify the observers about the new cursor notifyDataSetChanged(); } else { mDataValid = false; // notify the observers about the lack of a data set notifyDataSetInvalidated(); } return oldCursor; }
Example 14
Source File: CursorAdapter.java From letv with Apache License 2.0 | 5 votes |
public Cursor swapCursor(Cursor newCursor) { if (newCursor == this.mCursor) { return null; } Cursor oldCursor = this.mCursor; if (oldCursor != null) { if (this.mChangeObserver != null) { oldCursor.unregisterContentObserver(this.mChangeObserver); } if (this.mDataSetObserver != null) { oldCursor.unregisterDataSetObserver(this.mDataSetObserver); } } this.mCursor = newCursor; if (newCursor != null) { if (this.mChangeObserver != null) { newCursor.registerContentObserver(this.mChangeObserver); } if (this.mDataSetObserver != null) { newCursor.registerDataSetObserver(this.mDataSetObserver); } this.mRowIDColumn = newCursor.getColumnIndexOrThrow("_id"); this.mDataValid = true; notifyDataSetChanged(); return oldCursor; } this.mRowIDColumn = -1; this.mDataValid = false; notifyDataSetInvalidated(); return oldCursor; }
Example 15
Source File: CursorRecyclerAdapter.java From android-atleap with Apache License 2.0 | 5 votes |
/** * Swap in a new Cursor, returning the old Cursor. Unlike * {@link #changeCursor(Cursor)}, the returned old Cursor is <em>not</em> * closed. * * @param newCursor The new cursor to be used. * @return Returns the previously set Cursor, or null if there wasa not one. * If the given new Cursor is the same instance is the previously set * Cursor, null is also returned. */ public Cursor swapCursor(Cursor newCursor) { if (newCursor == mCursor) { return null; } Cursor oldCursor = mCursor; if (oldCursor != null) { if (mChangeObserver != null) oldCursor.unregisterContentObserver(mChangeObserver); if (mDataSetObserver != null) oldCursor.unregisterDataSetObserver(mDataSetObserver); } mCursor = newCursor; if (newCursor != null) { if (mChangeObserver != null) newCursor.registerContentObserver(mChangeObserver); if (mDataSetObserver != null) newCursor.registerDataSetObserver(mDataSetObserver); mRowIDColumn = newCursor.getColumnIndexOrThrow("_id"); mDataValid = true; // notify the observers about the new cursor notifyDataSetChanged(); } else { mRowIDColumn = -1; mDataValid = false; // notify the observers about the lack of a data set notifyDataSetChanged(); //notifyDataSetInvalidated(); } return oldCursor; }
Example 16
Source File: FavLoader.java From CSipSimple with GNU General Public License v3.0 | 5 votes |
/** * Helper function to take care of releasing resources associated with an * actively loaded data set. */ protected void onReleaseResources(Cursor c) { if(c != null) { c.unregisterContentObserver(loaderObserver); c.close(); } getContext().getContentResolver().unregisterContentObserver(loaderObserver); }
Example 17
Source File: AccountsLoader.java From CSipSimple with GNU General Public License v3.0 | 5 votes |
/** * Helper function to take care of releasing resources associated with an * actively loaded data set. */ protected void onReleaseResources(Cursor c) { if(c != null) { c.unregisterContentObserver(loaderObserver); c.close(); } if(loadStatus) { getContext().getContentResolver().unregisterContentObserver(loaderObserver); } }
Example 18
Source File: QueryResult.java From arca-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
public void unregisterContentObserver(final ContentObserver observer) { final Cursor cursor = getData(); if (cursor != null) { cursor.unregisterContentObserver(observer); } }
Example 19
Source File: TestProvider.java From Popular-Movies-App with Apache License 2.0 | 4 votes |
public void testUpdateMovie() { ContentValues testValues = TestUtilities.createTestMovieValues(); Uri movieUri = mContext.getContentResolver().insert(MoviesContract.MovieEntry.CONTENT_URI, testValues); assertTrue(movieUri != null); long movieId = ContentUris.parseId(movieUri); assertTrue(movieId != -1); assertEquals(movieUri, MoviesContract.MovieEntry.buildMovieUri(movieId)); ContentValues updatedValues = new ContentValues(testValues); updatedValues.put(MoviesContract.MovieEntry._ID, movieId); updatedValues.put(MoviesContract.MovieEntry.COLUMN_VOTE_COUNT, 100500); // Create a cursor with observer to make sure that the content provider is notifying // the observers as expected Cursor movies = mContext.getContentResolver().query( MoviesContract.MovieEntry.CONTENT_URI, null, null, null, null); assertTrue(movies != null); TestUtilities.TestContentObserver moviesObserver = TestUtilities.getTestContentObserver(); movies.registerContentObserver(moviesObserver); TestUtilities.TestContentObserver movieByIdObserver = TestUtilities.getTestContentObserver(); mContext.getContentResolver().registerContentObserver(movieUri, true, movieByIdObserver); int count = mContext.getContentResolver().update( MoviesContract.MovieEntry.CONTENT_URI, updatedValues, MoviesContract.MovieEntry._ID + "= ?", new String[]{Long.toString(movieId)}); assertEquals(1, count); // Test to make sure our observer is called. moviesObserver.waitForNotificationOrFail(); movies.unregisterContentObserver(moviesObserver); movies.close(); movieByIdObserver.waitForNotificationOrFail(); mContext.getContentResolver().unregisterContentObserver(movieByIdObserver); // A cursor is your primary interface to the query results. Cursor cursor = mContext.getContentResolver().query( MoviesContract.MovieEntry.CONTENT_URI, null, // projection MoviesContract.MovieEntry._ID + " = " + movieId, null, // Values for the "where" clause null // sort order ); assertTrue(cursor != null); TestUtilities.validateCursor("testUpdateMovie. Error validating movie entry update.", cursor, updatedValues); cursor.close(); }
Example 20
Source File: MediaStoreRecyclerAdapter.java From libcommon with Apache License 2.0 | 4 votes |
/** * カーソルを交換 * @param newCursor * @return */ @Nullable protected Cursor swapCursor(@Nullable final Cursor newCursor) { if (DEBUG) Log.v(TAG, "swapCursor:" + newCursor); Cursor oldCursor; synchronized (mValues) { if (newCursor == mCursor) { return null; } oldCursor = mCursor; } if (oldCursor != null) { if (mChangeObserver != null) { oldCursor.unregisterContentObserver(mChangeObserver); } if (mDataSetObserver != null) { oldCursor.unregisterDataSetObserver(mDataSetObserver); } } if (newCursor != null) { if (mChangeObserver != null) { newCursor.registerContentObserver(mChangeObserver); } if (mDataSetObserver != null) { newCursor.registerDataSetObserver(mDataSetObserver); } final List<MediaInfo> removes = new ArrayList<>(); final List<Integer> adds = new ArrayList<>(); if (newCursor.moveToFirst()) { int pos = 0; do { info.loadFromCursor(newCursor); if (DEBUG) Log.v(TAG, "swapCursor:" + info); if (!mNeedValidate || info.canRead(mCr)) { adds.add(pos); } else { removes.add(new MediaInfo(info)); } pos++; } while (newCursor.moveToNext()); } synchronized (mValues) { mValues.clear(); mValues.addAll(adds); mCursor = newCursor; } mDataValid = true; // notify the observers about the new cursor notifyDataSetChanged(); if (false) { // 読み込めないのがあれば削除を試みる if (!removes.isEmpty()) { for (final MediaInfo item: removes) { try { if(DEBUG) Log.v(TAG, "try to delete " + info); mCr.delete(item.getUri(), null, null); } catch (final Exception e) { Log.w(TAG, "failed to delete " + item, e); } } } } } else { mDataValid = false; // notify the observers about the lack of a data set synchronized (mValues) { mValues.clear(); mCursor = null; } notifyDataSetInvalidated(); } return oldCursor; }