Added in API level 1

MergeCursor


open class MergeCursor : AbstractCursor
kotlin.Any
   ↳ android.database.AbstractCursor
   ↳ android.database.MergeCursor

A convenience class that lets you present an array of Cursors as a single linear Cursor. The schema of the cursors presented is entirely up to the creator of the MergeCursor, and may be different if that is desired. Calls to getColumns, getColumnIndex, etc will return the value for the row that the MergeCursor is currently pointing at.

Summary

Public constructors
MergeCursor(cursors: Array<Cursor!>!)

Public methods
open Unit

Closes the Cursor, releasing all of its resources and making it completely invalid.

open Unit

Deactivates the Cursor, making all calls on it fail until requery is called.

open ByteArray!
getBlob(column: Int)

Returns the value of the requested column as a byte array.

open Array<String!>!

Returns a string array holding the names of all of the columns in the result set in the order in which they were listed in the result.

open Int

Returns the numbers of rows in the cursor.

open Double
getDouble(column: Int)

Returns the value of the requested column as a double.

open Float
getFloat(column: Int)

Returns the value of the requested column as a float.

open Int
getInt(column: Int)

Returns the value of the requested column as an int.

open Long
getLong(column: Int)

Returns the value of the requested column as a long.

open Short
getShort(column: Int)

Returns the value of the requested column as a short.

open String!
getString(column: Int)

Returns the value of the requested column as a String.

open Int
getType(column: Int)

Returns data type of the given column's value.

open Boolean
isNull(column: Int)

Returns true if the value in the indicated column is null.

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

Register an observer that is called when changes happen to the content backing this cursor.

open Unit

Register an observer that is called when changes happen to the contents of the this cursors data set, for example, when the data set is changed via requery(), deactivate(), or #close().

open Boolean

Performs the query that created the cursor again, refreshing its contents.

open Unit

Unregister an observer that has previously been registered with this cursor via registerContentObserver.

open Unit

Unregister an observer that has previously been registered with this cursor via registerContentObserver.

Inherited functions
Inherited properties

Public constructors

MergeCursor

Added in API level 1
MergeCursor(cursors: Array<Cursor!>!)

Public methods

close

Added in API level 1
open fun close(): Unit

Closes the Cursor, releasing all of its resources and making it completely invalid. Unlike deactivate() a call to requery() will not make the Cursor valid again.

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

deactivate

Added in API level 1
open fun deactivate(): Unit

Deactivates the Cursor, making all calls on it fail until requery is called. Inactive Cursors use fewer resources than active Cursors. Calling requery will make the cursor active again.

getBlob

Added in API level 1
open fun getBlob(column: Int): ByteArray!

Returns the value of the requested column as a byte array.

The result and whether this method throws an exception when the column value is null or the column type is not a blob type is implementation-defined.

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.

getColumnNames

Added in API level 1
open fun getColumnNames(): Array<String!>!

Returns a string array holding the names of all of the columns in the result set in the order in which they were listed in the result.

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

getCount

Added in API level 1
open fun getCount(): Int

Returns the numbers of rows in the cursor.

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

getDouble

Added in API level 1
open fun getDouble(column: Int): Double

Returns the value of the requested column as a double.

The result and whether this method throws an exception when the column value is null, the column type is not a floating-point type, or the floating-point value is not representable as a double value is implementation-defined.

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

Added in API level 1
open fun getFloat(column: Int): Float

Returns the value of the requested column as a float.

The result and whether this method throws an exception when the column value is null, the column type is not a floating-point type, or the floating-point value is not representable as a float value is implementation-defined.

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

Added in API level 1
open fun getInt(column: Int): Int

Returns the value of the requested column as an int.

The result and whether this method throws an exception when the column value is null, the column type is not an integral type, or the integer value is outside the range [Integer.MIN_VALUE, Integer.MAX_VALUE] is implementation-defined.

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

Added in API level 1
open fun getLong(column: Int): Long

Returns the value of the requested column as a long.

The result and whether this method throws an exception when the column value is null, the column type is not an integral type, or the integer value is outside the range [Long.MIN_VALUE, Long.MAX_VALUE] is implementation-defined.

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.

getShort

Added in API level 1
open fun getShort(column: Int): Short

Returns the value of the requested column as a short.

The result and whether this method throws an exception when the column value is null, the column type is not an integral type, or the integer value is outside the range [Short.MIN_VALUE, Short.MAX_VALUE] is implementation-defined.

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

Added in API level 1
open fun getString(column: Int): String!

Returns the value of the requested column as a String.

The result and whether this method throws an exception when the column value is null or the column type is not a string type is implementation-defined.

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.

getType

Added in API level 11
open fun getType(column: Int): Int

Returns data type of the given column's value. The preferred type of the column is returned but the data may be converted to other types as documented in the get-type methods such as getInt(int), getFloat(int) etc.

Parameters
columnIndex the zero-based index of the target column.
Value is 0 or greater
Return
Int column value type.
Value is one of the following:

isNull

Added in API level 1
open fun isNull(column: Int): Boolean

Returns true if the value in the indicated column is null.

Parameters
columnIndex the zero-based index of the target column.
Value is 0 or greater
Return
Boolean whether the column value is null.

onMove

Added in API level 1
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

Added in API level 1
open fun registerContentObserver(observer: ContentObserver!): Unit

Register an observer that is called when changes happen to the content backing this cursor. Typically the data set won't change until requery() is called.

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

registerDataSetObserver

Added in API level 1
open fun registerDataSetObserver(observer: DataSetObserver!): Unit

Register an observer that is called when changes happen to the contents of the this cursors data set, for example, when the data set is changed via requery(), deactivate(), or #close().

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

requery

Added in API level 1
open fun requery(): Boolean

Performs the query that created the cursor again, refreshing its contents. This may be done at any time, including after a call to deactivate. Since this method could execute a query on the database and potentially take a while, it could cause ANR if it is called on Main (UI) thread. A warning is printed if this method is being executed on Main thread.

Return
Boolean true if the requery succeeded, false if not, in which case the cursor becomes invalid.

unregisterContentObserver

Added in API level 1
open fun unregisterContentObserver(observer: ContentObserver!): Unit

Unregister an observer that has previously been registered with this cursor via registerContentObserver.

Parameters
observer ContentObserver!: the object to unregister.

unregisterDataSetObserver

Added in API level 1
open fun unregisterDataSetObserver(observer: DataSetObserver!): Unit

Unregister an observer that has previously been registered with this cursor via registerContentObserver.

Parameters
observer DataSetObserver!: the object to unregister.