Code example for Cursor

Methods: closeisClosed

0
 
		if (isStarted()) {
			super.deliverResult(data);
		} 
 
		if (oldCursor != null && oldCursor != data && !oldCursor.isClosed()) {
			onReleaseResources(oldCursor);
		} 
	} 
 
	@Override 
	protected void onStartLoading() { 
		if (mCursor != null){
			deliverResult(mCursor);
		} 
         
        if (takeContentChanged() || mCursor == null) {
            // If the data has changed since the last time it was loaded 
            // or is not currently available, start a load. 
            forceLoad();
        } 
	} 
	 
	@Override 
	protected void onStopLoading() { 
		cancelLoad();
	} 
	 
	@Override 
	public void onCanceled(Cursor data) {
		super.onCanceled(data);
		onReleaseResources(data);
	} 
	 
	/** 
     * Handles a request to completely reset the Loader. 
     */ 
	@Override 
	protected void onReset() { 
		super.onReset(); 
		 
		onStopLoading(); 
 
        // At this point we can release the resources associated with 'mCursor' 
        // if needed. 
        if (mCursor != null && !mCursor.isClosed()) {
            onReleaseResources(mCursor);           
        }	 
        mCursor = null;
	} 
	 
	/** 
     * Helper function to take care of releasing resources associated 
     * with an actively loaded data set. 
     * @param c {@link Cursor} to be released 
     */ 
	protected void onReleaseResources(Cursor c) {
		if (c != null)
			c.close();		
		 
		if (mDatabaseAdapter != null){
			mDatabaseAdapter.close();
		} 
	}