FileDocCategorySizeDatePackage
SQLiteClosable.javaAPI DocAndroid 5.1 API3238Thu Mar 12 22:22:10 GMT 2015android.database.sqlite

SQLiteClosable

public abstract class SQLiteClosable extends Object implements Closeable
An object created from a SQLiteDatabase that can be closed. This class implements a primitive reference counting scheme for database objects.

Fields Summary
private int
mReferenceCount
Constructors Summary
Methods Summary
public voidacquireReference()
Acquires a reference to the object.

throws
IllegalStateException if the last reference to the object has already been released.

        synchronized(this) {
            if (mReferenceCount <= 0) {
                throw new IllegalStateException(
                        "attempt to re-open an already-closed object: " + this);
            }
            mReferenceCount++;
        }
    
public voidclose()
Releases a reference to the object, closing the object if the last reference was released. Calling this method is equivalent to calling {@link #releaseReference}.

see
#releaseReference()
see
#onAllReferencesReleased()

        releaseReference();
    
protected abstract voidonAllReferencesReleased()
Called when the last reference to the object was released by a call to {@link #releaseReference()} or {@link #close()}.

protected voidonAllReferencesReleasedFromContainer()
Called when the last reference to the object was released by a call to {@link #releaseReferenceFromContainer()}.

deprecated
Do not use.


                            
       

                             
    
       
        onAllReferencesReleased();
    
public voidreleaseReference()
Releases a reference to the object, closing the object if the last reference was released.

see
#onAllReferencesReleased()

        boolean refCountIsZero = false;
        synchronized(this) {
            refCountIsZero = --mReferenceCount == 0;
        }
        if (refCountIsZero) {
            onAllReferencesReleased();
        }
    
public voidreleaseReferenceFromContainer()
Releases a reference to the object that was owned by the container of the object, closing the object if the last reference was released.

see
#onAllReferencesReleasedFromContainer()
deprecated
Do not use.

        boolean refCountIsZero = false;
        synchronized(this) {
            refCountIsZero = --mReferenceCount == 0;
        }
        if (refCountIsZero) {
            onAllReferencesReleasedFromContainer();
        }