MatrixCursor

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

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(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(String, 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
<init>(columnNames: Array<String!>!, initialCapacity: Int)

Constructs a new cursor with the given initial capacity.

<init>(columnNames: Array<String!>!)

Constructs a new cursor.

Public methods
open Long
getLong(column: Int)

open Int

open Array<String!>!

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

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

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

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

open Short
getShort(column: Int)

open Float
getFloat(column: Int)

open Double
getDouble(column: Int)

open MatrixCursor.RowBuilder!

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

open Boolean
isNull(column: Int)

open Int
getInt(column: Int)

open Int
getType(column: Int)

Returns data type of the given column's value.

open ByteArray!
getBlob(column: Int)

open String!
getString(column: Int)

Inherited functions
Inherited properties

Public constructors

<init>

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 Array<String!>!: in rows

<init>

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

Public methods

getLong

open fun getLong(column: Int): Long

getCount

open fun getCount(): Int

getColumnNames

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

addRow

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
IllegalArgumentException if columnValues.length != columnNames.length

addRow

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
IllegalArgumentException if columnValues.size() != columnNames.length

getShort

open fun getShort(column: Int): Short

getFloat

open fun getFloat(column: Int): Float

getDouble

open fun getDouble(column: Int): Double

newRow

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

isNull

open fun isNull(column: Int): Boolean

getInt

open fun getInt(column: Int): Int

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.

Returned column types are


Requires API level 11 (Android 3.0, Honeycomb) Requires API level 11 (Android 3.0, Honeycomb) Requires API level 11 (Android 3.0, Honeycomb)
Parameters
columnIndex Int: the zero-based index of the target column.
Return
Int: column value type

getBlob

open fun getBlob(column: Int): ByteArray!

getString

open fun getString(column: Int): String!