Code example for CursorLoader

Methods: setUpdateThrottle

0
		// These are the rows that we will retrieve. 
		static final String[] PROJECTION = new String[] { MainTable._ID,
				MainTable.COLUMN_NAME_DATA, };
 
		public Loader<Cursor> onCreateLoader(int id, Bundle args) {
			CursorLoader cl = new CursorLoader(getActivity(),
					MainTable.CONTENT_URI, PROJECTION, null, null, null);
			cl.setUpdateThrottle(2000); // update at most every 2 seconds.
			return cl;
		} 
 
		public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
			mAdapter.swapCursor(data);
 
			// The list should now be shown. 
			if (isResumed()) {
				setListShown(true);
			} else { 
				setListShownNoAnimation(true);
			} 
		}