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 constructors
AbstractCursor()
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!)
Protected methods
open Unit checkPosition() This function throws CursorIndexOutOfBoundsException if the cursor position is out of bounds.
open Unit finalize()
open Any! getUpdatedField(columnIndex: Int)
open Boolean isFieldUpdated(columnIndex: Int)
open Unit onChange(selfChange: Boolean) Subclasses must call this method when they finish committing updates to notify all observers.
Properties
Boolean mClosed
ContentResolver! mContentResolver
Int mPos

Public constructors

AbstractCursor

AbstractCursor()

Public methods

close

open fun close(): Unit

Exceptions
java.lang.Exception if this resource cannot be closed
java.io.IOException if an I/O error occurs

copyStringToBuffer

open 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.

deactivate

open fun deactivate(): Unit

fillWindow

open 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.

getBlob

open 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.

getColumnCount

open fun getColumnCount(): Int

Return
Int number of columns Value is 0 or greater

getColumnIndex

open 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

getColumnIndexOrThrow

open 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

getColumnName

open 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.

getColumnNames

abstract fun getColumnNames(): Array<String!>!

Return
Array<String!>! the names of the columns returned in this query.

getCount

abstract fun getCount(): Int

Return
Int the number of rows in the cursor. Value is 0 or greater

getDouble

abstract 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.

getFloat

abstract 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.

getInt

abstract 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.

getLong

abstract 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.

getNotificationUri

open fun getNotificationUri(): Uri!

Return
Uri! Returns a URI that can be used with ContentResolver.registerContentObserver to find out about changes to this Cursor's data. May be null if no notification URI has been set.

getPosition

fun getPosition(): Int

Return
Int the current cursor position. Value is -1 or greater

getShort

abstract 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.

getString

abstract 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.

getWantsAllOnMoveCalls

open fun getWantsAllOnMoveCalls(): Boolean

Return
Boolean whether all cursor movement should result in a call to onMove().

getWindow

open 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.

isAfterLast

fun isAfterLast(): Boolean

Return
Boolean whether the cursor is after the last result.

isBeforeFirst

fun isBeforeFirst(): Boolean

Return
Boolean whether the cursor is before the first result.

isClosed

open fun isClosed(): Boolean

Return
Boolean true if the cursor is closed.

isFirst

fun isFirst(): Boolean

Return
Boolean whether the cursor is pointing at the first entry.

isLast

fun isLast(): Boolean

Return
Boolean whether the cursor is pointing at the last entry.

isNull

abstract 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.

move

fun move(offset: Int): Boolean

Parameters
offset Int: the offset to be applied from the current position.
Return
Boolean whether the requested move fully succeeded.

moveToFirst

fun moveToFirst(): Boolean

Return
Boolean whether the move succeeded.

moveToLast

fun moveToLast(): Boolean

Return
Boolean whether the move succeeded.

moveToNext

fun moveToNext(): Boolean

Return
Boolean whether the move succeeded.

moveToPosition

fun 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.

moveToPrevious

fun moveToPrevious(): Boolean

Return
Boolean whether the move succeeded.

onMove

open 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

registerContentObserver

open fun registerContentObserver(observer: ContentObserver!): Unit

Parameters
observer ContentObserver!: the object that gets notified when the content backing the cursor changes.

registerDataSetObserver

open fun registerDataSetObserver(observer: DataSetObserver!): Unit

Parameters
observer DataSetObserver!: the object that gets notified when the cursors data set changes.

requery

open 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.

setNotificationUri

open 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

checkPosition

protected 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

finalize

protected open fun finalize(): Unit

Exceptions
java.lang.Throwable the Exception raised by this method

getUpdatedField

protected open fun getUpdatedField(columnIndex: Int): Any!

Deprecated: Always returns null since Cursors do not support updating rows

isFieldUpdated

protected open fun isFieldUpdated(columnIndex: Int): Boolean

Deprecated: Always returns false since Cursors do not support updating rows

onChange

protected open fun onChange(selfChange: Boolean): Unit

Subclasses must call this method when they finish committing updates to notify all observers.

Parameters
selfChange Boolean:

Properties

mClosed

protected var mClosed: Boolean

Deprecated: Use [isClosed()](#isClosed%28%29) instead.

mContentResolver

protected var mContentResolver: ContentResolver!

Deprecated: Do not use.

mPos

protected var mPos: Int

Deprecated: Use [getPosition()](#getPosition%28%29) instead.