Added in API level 1

MatrixCursor


open class MatrixCursor : AbstractCursor

A mutable cursor implementation backed by an array of Objects. Use newRow() to add rows. Automatically expands internal capacity as needed.

Summary

Nested classes
open

Builds a row of values using either of these approaches:

  • Values can be added with explicit column ordering using add(java.lang.Object), which starts from the left-most column and adds one column value at a time. This follows the same ordering as the column names specified at cursor construction time.
  • Column and value pairs can be offered for possible inclusion using add(java.lang.String,java.lang.Object). If the cursor includes the given column, the value will be set for that column, otherwise the value is ignored. This approach is useful when matching data to a custom projection.
Undefined values are left as null.

Public constructors
MatrixCursor(columnNames: Array<String!>!)

Constructs a new cursor.

MatrixCursor(columnNames: Array<String!>!, initialCapacity: Int)

Constructs a new cursor with the given initial capacity.

Public methods
open Unit
addRow(columnValues: MutableIterable<*>!)

Adds a new row to the end with the given column values.

open Unit
addRow(columnValues: Array<Any!>!)

Adds a new row to the end with the given column values.

open ByteArray!
getBlob(column: Int)

open Array<String!>!

open Int

open Double
getDouble(column: Int)

open Float
getFloat(column: Int)

open Int
getInt(column: Int)

open Long
getLong(column: Int)

open Short
getShort(column: Int)

open String!
getString(column: Int)

open Int
getType(column: Int)

open Boolean
isNull(column: Int)

open MatrixCursor.RowBuilder!

Adds a new row to the end and returns a builder for that row.

Inherited functions
Unit checkPosition()

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.

Unit close()

Unit copyStringToBuffer(columnIndex: Int, buffer: CharArrayBuffer!)

Unit deactivate()

Unit fillWindow(position: Int, window: CursorWindow!)

Unit finalize()

Int getColumnCount()

Int getColumnIndex(columnName: String!)

Int getColumnIndexOrThrow(columnName: String!)

String! getColumnName(columnIndex: Int)

Bundle! getExtras()

Uri! getNotificationUri()

MutableList<Uri!>? getNotificationUris()

Int getPosition()

Any! getUpdatedField(columnIndex: Int)

Boolean getWantsAllOnMoveCalls()

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()

Boolean isClosed()

Boolean isFieldUpdated(columnIndex: Int)

Boolean isFirst()

Boolean isLast()

Boolean move(offset: Int)

Boolean moveToFirst()

Boolean moveToLast()

Boolean moveToNext()

Boolean moveToPosition(position: Int)

Boolean moveToPrevious()

Unit onChange(selfChange: Boolean)

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

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. If it returns false the move function will also do so and the cursor will scroll to the beforeFirst position.

Unit registerContentObserver(observer: ContentObserver!)

Unit registerDataSetObserver(observer: DataSetObserver!)

Boolean requery()

Bundle! respond(extras: Bundle!)

Unit setExtras(extras: Bundle!)

Unit setNotificationUri(cr: ContentResolver!, notifyUri: Uri!)

Specifies a content URI to watch for changes.

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.

If this is not implemented, this is equivalent to calling setNotificationUri(android.content.ContentResolver,android.net.Uri) with the first URI in uris.

Calling this overrides any previous call to setNotificationUri(android.content.ContentResolver,android.net.Uri).

Unit unregisterContentObserver(observer: ContentObserver!)

Unit unregisterDataSetObserver(observer: DataSetObserver!)

Public constructors

MatrixCursor

Added in API level 1
MatrixCursor(columnNames: Array<String!>!)

Constructs a new cursor.

Parameters
columnNames Array<String!>!: names of the columns, the ordering of which determines column ordering elsewhere in this cursor

MatrixCursor

Added in API level 1
MatrixCursor(
    columnNames: Array<String!>!,
    initialCapacity: Int)

Constructs a new cursor with the given initial capacity.

Parameters
columnNames Array<String!>!: names of the columns, the ordering of which determines column ordering elsewhere in this cursor
initialCapacity Int: in rows

Public methods

addRow

Added in API level 1
open fun addRow(columnValues: MutableIterable<*>!): Unit

Adds a new row to the end with the given column values. Not safe for concurrent use.

Parameters
columnValues MutableIterable<*>!: in the same order as the the column names specified at cursor construction time
Exceptions
java.lang.IllegalArgumentException if columnValues.size() != columnNames.length

addRow

Added in API level 1
open fun addRow(columnValues: Array<Any!>!): Unit

Adds a new row to the end with the given column values. Not safe for concurrent use.

Parameters
columnValues Array<Any!>!: in the same order as the the column names specified at cursor construction time
Exceptions
java.lang.IllegalArgumentException if columnValues.length != columnNames.length

getBlob

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

getColumnNames

Added in API level 1
open fun getColumnNames(): Array<String!>!
Return
Array<String!>! the names of the columns returned in this query.

getCount

Added in API level 1
open fun getCount(): Int
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
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
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
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
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
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!
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
Parameters
columnIndex the zero-based index of the target column. Value is 0 or greater

isNull

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

newRow

Added in API level 1
open fun newRow(): MatrixCursor.RowBuilder!

Adds a new row to the end and returns a builder for that row. Not safe for concurrent use.

Return
MatrixCursor.RowBuilder! builder which can be used to set the column values for the new row