AbstractCursor | API reference | Android Developers (original ) (raw )
abstract class AbstractCursor : CrossProcessCursor
This is an abstract cursor class that handles a lot of the common code that all cursors need to deal with and is provided for convenience reasons.
Summary
Nested classes
open
SelfContentObserver Cursors use this class to track changes others make to their URI.
Public methods
open Unit
close ()
open Unit
copyStringToBuffer (columnIndex: Int , buffer: CharArrayBuffer !)
open Unit
deactivate ()
open Unit
fillWindow (position: Int , window: CursorWindow !)
open ByteArray !
getBlob (column: Int )
open Int
getColumnCount ()
open Int
getColumnIndex (columnName: String !)
open Int
getColumnIndexOrThrow (columnName: String !)
open String !
getColumnName (columnIndex: Int )
abstract Array <String !>!
getColumnNames ()
abstract Int
getCount ()
abstract Double
getDouble (column: Int )
open Bundle !
getExtras ()
abstract Float
getFloat (column: Int )
abstract Int
getInt (column: Int )
abstract Long
getLong (column: Int )
open Uri !
getNotificationUri ()
open MutableList <Uri !>?
getNotificationUris ()
Int
getPosition ()
abstract Short
getShort (column: Int )
abstract String !
getString (column: Int )
open Int
getType (column: Int )
open Boolean
getWantsAllOnMoveCalls ()
open CursorWindow !
getWindow () If the cursor is backed by a CursorWindow , returns a pre-filled window with the contents of the cursor, otherwise null.
Boolean
isAfterLast ()
Boolean
isBeforeFirst ()
open Boolean
isClosed ()
Boolean
isFirst ()
Boolean
isLast ()
abstract Boolean
isNull (column: Int )
Boolean
move (offset: Int )
Boolean
moveToFirst ()
Boolean
moveToLast ()
Boolean
moveToNext ()
Boolean
moveToPosition (position: Int )
Boolean
moveToPrevious ()
open Boolean
onMove (oldPosition: Int , newPosition: Int ) This function is called every time the cursor is successfully scrolled to a new position, giving the subclass a chance to update any state it may have.
open Unit
registerContentObserver (observer: ContentObserver !)
open Unit
registerDataSetObserver (observer: DataSetObserver !)
open Boolean
requery ()
open Bundle !
respond (extras: Bundle !)
open Unit
setExtras (extras: Bundle !)
open Unit
setNotificationUri (cr: ContentResolver !, notifyUri: Uri !) Specifies a content URI to watch for changes.
open Unit
setNotificationUris (cr: ContentResolver , notifyUris: MutableList <Uri !>) Similar to setNotificationUri(android.content.ContentResolver,android.net.Uri) , except this version allows to watch multiple content URIs for changes.
open Unit
unregisterContentObserver (observer: ContentObserver !)
open Unit
unregisterDataSetObserver (observer: DataSetObserver !)
Public constructors AbstractCursorAbstractCursor()
Public methods closeopen fun close(): Unit
Exceptions
java.lang.Exception
if this resource cannot be closed
java.io.IOException
if an I/O error occurs
copyStringToBufferopen fun copyStringToBuffer( columnIndex: Int , buffer: CharArrayBuffer ! ): Unit
Parameters
columnIndex
Int : the zero-based index of the target column. if the target column is null, return buffer Value is 0 or greater
buffer
CharArrayBuffer !: the buffer to copy the text into.
deactivateopen fun deactivate(): Unit
fillWindowopen fun fillWindow( position: Int , window: CursorWindow ! ): Unit
Parameters
position
Int : The zero-based index of the first row to copy into the window.
window
CursorWindow !: The window to fill.
getBlobopen fun getBlob(column: Int ): ByteArray !
Parameters
columnIndex
the zero-based index of the target column. Value is 0 or greater
Return
ByteArray !
the value of that column as a byte array.
getColumnCountopen fun getColumnCount(): Int
Return
Int
number of columns Value is 0 or greater
getColumnIndexopen fun getColumnIndex(columnName: String !): Int
Parameters
columnName
String !: the name of the target column.
Return
Int
the zero-based column index for the given column name, or -1 if the column name does not exist. Value is -1 or greater
getColumnIndexOrThrowopen fun getColumnIndexOrThrow(columnName: String !): Int
Parameters
columnName
String !: the name of the target column.
Return
Int
the zero-based column index for the given column name Value is 0 or greater
Exceptions
java.lang.IllegalArgumentException
if the column does not exist
getColumnNameopen fun getColumnName(columnIndex: Int ): String !
Parameters
columnIndex
Int : the zero-based index of the target column. Value is 0 or greater
Return
String !
the column name for the given column index.
getColumnNamesabstract fun getColumnNames(): Array <String !>!
Return
Array <String !>!
the names of the columns returned in this query.
getCountabstract fun getCount(): Int
Return
Int
the number of rows in the cursor. Value is 0 or greater
getDoubleabstract fun getDouble(column: Int ): Double
Parameters
columnIndex
the zero-based index of the target column. Value is 0 or greater
Return
Double
the value of that column as a double.
getFloatabstract fun getFloat(column: Int ): Float
Parameters
columnIndex
the zero-based index of the target column. Value is 0 or greater
Return
Float
the value of that column as a float.
getIntabstract fun getInt(column: Int ): Int
Parameters
columnIndex
the zero-based index of the target column. Value is 0 or greater
Return
Int
the value of that column as an int.
getLongabstract fun getLong(column: Int ): Long
Parameters
columnIndex
the zero-based index of the target column. Value is 0 or greater
Return
Long
the value of that column as a long.
getNotificationUriopen fun getNotificationUri(): Uri !
getPositionfun getPosition(): Int
Return
Int
the current cursor position. Value is -1 or greater
getShortabstract fun getShort(column: Int ): Short
Parameters
columnIndex
the zero-based index of the target column. Value is 0 or greater
Return
Short
the value of that column as a short.
getStringabstract fun getString(column: Int ): String !
Parameters
columnIndex
the zero-based index of the target column. Value is 0 or greater
Return
String !
the value of that column as a String.
getWantsAllOnMoveCallsopen fun getWantsAllOnMoveCalls(): Boolean
Return
Boolean
whether all cursor movement should result in a call to onMove().
getWindowopen fun getWindow(): CursorWindow !
If the cursor is backed by a [CursorWindow](/reference/kotlin/android/database/CursorWindow)
, returns a pre-filled window with the contents of the cursor, otherwise null.
Return
CursorWindow !
The pre-filled window that backs this cursor, or null if none.
isAfterLastfun isAfterLast(): Boolean
Return
Boolean
whether the cursor is after the last result.
isBeforeFirstfun isBeforeFirst(): Boolean
Return
Boolean
whether the cursor is before the first result.
isClosedopen fun isClosed(): Boolean
Return
Boolean
true if the cursor is closed.
isFirstfun isFirst(): Boolean
Return
Boolean
whether the cursor is pointing at the first entry.
isLastfun isLast(): Boolean
Return
Boolean
whether the cursor is pointing at the last entry.
isNullabstract fun isNull(column: Int ): Boolean
Parameters
columnIndex
the zero-based index of the target column. Value is 0 or greater
Return
Boolean
whether the column value is null.
movefun move(offset: Int ): Boolean
Parameters
offset
Int : the offset to be applied from the current position.
Return
Boolean
whether the requested move fully succeeded.
moveToFirstfun moveToFirst(): Boolean
Return
Boolean
whether the move succeeded.
moveToLastfun moveToLast(): Boolean
Return
Boolean
whether the move succeeded.
moveToNextfun moveToNext(): Boolean
Return
Boolean
whether the move succeeded.
moveToPositionfun moveToPosition(position: Int ): Boolean
Parameters
position
Int : the zero-based position to move to. Value is -1 or greater
Return
Boolean
whether the requested move fully succeeded.
moveToPreviousfun moveToPrevious(): Boolean
Return
Boolean
whether the move succeeded.
onMoveopen fun onMove( oldPosition: Int , newPosition: Int ): Boolean
This function is called every time the cursor is successfully scrolled to a new position, giving the subclass a chance to update any state it may have. If it returns false the move function will also do so and the cursor will scroll to the beforeFirst position.
Parameters
oldPosition
Int : the position that we're moving from
newPosition
Int : the position that we're moving to
Return
Boolean
true if the move is successful, false otherwise
registerContentObserveropen fun registerContentObserver(observer: ContentObserver !): Unit
Parameters
observer
ContentObserver !: the object that gets notified when the content backing the cursor changes.
registerDataSetObserveropen fun registerDataSetObserver(observer: DataSetObserver !): Unit
Parameters
observer
DataSetObserver !: the object that gets notified when the cursors data set changes.
requeryopen fun requery(): Boolean
Return
Boolean
true if the requery succeeded, false if not, in which case the cursor becomes invalid.
open fun setExtras(extras: Bundle !): Unit
Parameters
extras
Bundle !: Bundle to set, or null to set an empty bundle.
setNotificationUriopen fun setNotificationUri( cr: ContentResolver !, notifyUri: Uri ! ): Unit
Specifies a content URI to watch for changes.
Parameters
cr
ContentResolver !: The content resolver from the caller's context.
uri
The content URI to watch.
notifyUri
Uri !: The URI to watch for changes. This can be a specific row URI, or a base URI for a whole class of content.
Protected methods checkPositionprotected open fun checkPosition(): Unit
This function throws CursorIndexOutOfBoundsException if the cursor position is out of bounds. Subclass implementations of the get functions should call this before attempting to retrieve data.
Exceptions
android.database.CursorIndexOutOfBoundsException
finalizeprotected open fun finalize(): Unit
Exceptions
java.lang.Throwable
the Exception raised by this method
getUpdatedFieldprotected open fun getUpdatedField(columnIndex: Int ): Any !
Deprecated: Always returns null since Cursors do not support updating rows
isFieldUpdatedprotected open fun isFieldUpdated(columnIndex: Int ): Boolean
Deprecated: Always returns false since Cursors do not support updating rows
onChangeprotected open fun onChange(selfChange: Boolean ): Unit
Subclasses must call this method when they finish committing updates to notify all observers.
Properties mClosedprotected var mClosed: Boolean
Deprecated: Use [isClosed()](#isClosed%28%29)
instead.
mContentResolverprotected var mContentResolver: ContentResolver !
Deprecated: Do not use.
mPosprotected var mPos: Int
Deprecated: Use [getPosition()](#getPosition%28%29)
instead.