Added in API level 1

CursorWindow


open class CursorWindow : SQLiteClosable, Parcelable
kotlin.Any
   ↳ android.database.sqlite.SQLiteClosable
   ↳ android.database.CursorWindow

A buffer containing multiple cursor rows.

A CursorWindow is read-write when initially created and used locally. When sent to a remote process (by writing it to a Parcel), the remote process receives a read-only view of the cursor window. Typically the cursor window will be allocated by the producer, filled with data, and then sent to the consumer for reading.

Summary

Inherited constants
Public constructors

Creates a new empty cursor window and gives it a name.

CursorWindow(name: String!, windowSizeBytes: Long)

Creates a new empty cursor window and gives it a name.

CursorWindow(localWindow: Boolean)

Creates a new empty cursor window.

Public methods
open Boolean

Allocates a new row at the end of this cursor window.

open Unit

Clears out the existing contents of the window, making it safe to reuse for new data.

open Unit
copyStringToBuffer(row: Int, column: Int, buffer: CharArrayBuffer!)

Copies the text of the field at the specified row and column index into a CharArrayBuffer.

open Int

open Unit

Frees the last row in this cursor window.

open ByteArray!
getBlob(row: Int, column: Int)

Gets the value of the field at the specified row and column index as a byte array.

open Double
getDouble(row: Int, column: Int)

Gets the value of the field at the specified row and column index as a double.

open Float
getFloat(row: Int, column: Int)

Gets the value of the field at the specified row and column index as a float.

open Int
getInt(row: Int, column: Int)

Gets the value of the field at the specified row and column index as an int.

open Long
getLong(row: Int, column: Int)

Gets the value of the field at the specified row and column index as a long.

open Int

Gets the number of rows in this window.

open Short
getShort(row: Int, column: Int)

Gets the value of the field at the specified row and column index as a short.

open Int

Gets the start position of this cursor window.

open String!
getString(row: Int, column: Int)

Gets the value of the field at the specified row and column index as a string.

open Int
getType(row: Int, column: Int)

Returns the type of the field at the specified row and column index.

open Boolean
isBlob(row: Int, column: Int)

Returns true if the field at the specified row and column index has type Cursor#FIELD_TYPE_BLOB or Cursor#FIELD_TYPE_NULL.

open Boolean
isFloat(row: Int, column: Int)

Returns true if the field at the specified row and column index has type Cursor#FIELD_TYPE_FLOAT.

open Boolean
isLong(row: Int, column: Int)

Returns true if the field at the specified row and column index has type Cursor#FIELD_TYPE_INTEGER.

open Boolean
isNull(row: Int, column: Int)

Returns true if the field at the specified row and column index has type Cursor#FIELD_TYPE_NULL.

open Boolean
isString(row: Int, column: Int)

Returns true if the field at the specified row and column index has type Cursor#FIELD_TYPE_STRING or Cursor#FIELD_TYPE_NULL.

open static CursorWindow!

open Boolean
putBlob(value: ByteArray!, row: Int, column: Int)

Copies a byte array into the field at the specified row and column index.

open Boolean
putDouble(value: Double, row: Int, column: Int)

Puts a double-precision floating point value into the field at the specified row and column index.

open Boolean
putLong(value: Long, row: Int, column: Int)

Puts a long integer into the field at the specified row and column index.

open Boolean
putNull(row: Int, column: Int)

Puts a null value into the field at the specified row and column index.

open Boolean
putString(value: String!, row: Int, column: Int)

Copies a string into the field at the specified row and column index.

open Boolean
setNumColumns(columnNum: Int)

Sets the number of columns in this window.

open Unit

Sets the start position of this cursor window.

open String

open Unit
writeToParcel(dest: Parcel, flags: Int)

Protected methods
open Unit

open Unit

Inherited functions
Properties
static Parcelable.Creator<CursorWindow!>

Public constructors

CursorWindow

Added in API level 15
CursorWindow(name: String!)

Creates a new empty cursor window and gives it a name.

The cursor initially has no rows or columns. Call setNumColumns(int) to set the number of columns before adding any rows to the cursor.

Parameters
name String!: The name of the cursor window, or null if none.

CursorWindow

Added in API level 28
CursorWindow(
    name: String!,
    windowSizeBytes: Long)

Creates a new empty cursor window and gives it a name.

The cursor initially has no rows or columns. Call setNumColumns(int) to set the number of columns before adding any rows to the cursor.

Parameters
name String!: The name of the cursor window, or null if none.
windowSizeBytes Long: Size of cursor window in bytes. Value is a non-negative number of bytes.
Exceptions
java.lang.IllegalArgumentException if windowSizeBytes is less than 0
java.lang.AssertionError if created window pointer is 0

Note: Memory is dynamically allocated as data rows are added to the window. Depending on the amount of data stored, the actual amount of memory allocated can be lower than specified size, but cannot exceed it.

CursorWindow

Added in API level 1
CursorWindow(localWindow: Boolean)

Deprecated: There is no longer a distinction between local and remote cursor windows. Use the CursorWindow(java.lang.String) constructor instead.

Creates a new empty cursor window.

The cursor initially has no rows or columns. Call setNumColumns(int) to set the number of columns before adding any rows to the cursor.

Parameters
localWindow Boolean: True if this window will be used in this process only, false if it might be sent to another processes. This argument is ignored.

Public methods

allocRow

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

Allocates a new row at the end of this cursor window.

Return
Boolean True if successful, false if the cursor window is out of memory.

clear

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

Clears out the existing contents of the window, making it safe to reuse for new data.

The start position (getStartPosition()), number of rows (getNumRows()), and number of columns in the cursor are all reset to zero.

copyStringToBuffer

Added in API level 1
open fun copyStringToBuffer(
    row: Int,
    column: Int,
    buffer: CharArrayBuffer!
): Unit

Copies the text of the field at the specified row and column index into a CharArrayBuffer.

The buffer is populated as follows:

  • If the buffer is too small for the value to be copied, then it is automatically resized.
  • If the field is of type Cursor#FIELD_TYPE_NULL, then the buffer is set to an empty string.
  • If the field is of type Cursor#FIELD_TYPE_STRING, then the buffer is set to the contents of the string.
  • If the field is of type Cursor#FIELD_TYPE_INTEGER, then the buffer is set to a string representation of the integer in decimal, obtained by formatting the value with the printf family of functions using format specifier %lld.
  • If the field is of type Cursor#FIELD_TYPE_FLOAT, then the buffer is set to a string representation of the floating-point value in decimal, obtained by formatting the value with the printf family of functions using format specifier %g.
  • If the field is of type Cursor#FIELD_TYPE_BLOB, then a SQLiteException is thrown.

Parameters
row Int: The zero-based row index. Value is 0 or greater
column Int: The zero-based column index. Value is 0 or greater
buffer CharArrayBuffer!: The CharArrayBuffer to hold the string. It is automatically resized if the requested string is larger than the buffer's current capacity.

describeContents

Added in API level 1
open fun describeContents(): Int
Return
Int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR

freeLastRow

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

Frees the last row in this cursor window.

getBlob

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

Gets the value of the field at the specified row and column index as a byte array.

The result is determined as follows:

Parameters
row Int: The zero-based row index. Value is 0 or greater
column Int: The zero-based column index. Value is 0 or greater
Return
ByteArray! The value of the field as a byte array.

getDouble

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

Gets the value of the field at the specified row and column index as a double.

The result is determined as follows:

Parameters
row Int: The zero-based row index. Value is 0 or greater
column Int: The zero-based column index. Value is 0 or greater
Return
Double The value of the field as a double.

getFloat

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

Gets the value of the field at the specified row and column index as a float.

The result is determined by invoking getDouble and converting the result to float.

Parameters
row Int: The zero-based row index. Value is 0 or greater
column Int: The zero-based column index. Value is 0 or greater
Return
Float The value of the field as an float.

getInt

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

Gets the value of the field at the specified row and column index as an int.

The result is determined by invoking getLong and converting the result to int.

Parameters
row Int: The zero-based row index. Value is 0 or greater
column Int: The zero-based column index. Value is 0 or greater
Return
Int The value of the field as an int.

getLong

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

Gets the value of the field at the specified row and column index as a long.

The result is determined as follows:

Parameters
row Int: The zero-based row index. Value is 0 or greater
column Int: The zero-based column index. Value is 0 or greater
Return
Long The value of the field as a long.

getNumRows

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

Gets the number of rows in this window.

Return
Int The number of rows in this cursor window. Value is 0 or greater

getShort

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

Gets the value of the field at the specified row and column index as a short.

The result is determined by invoking getLong and converting the result to short.

Parameters
row Int: The zero-based row index. Value is 0 or greater
column Int: The zero-based column index. Value is 0 or greater
Return
Short The value of the field as a short.

getStartPosition

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

Gets the start position of this cursor window.

The start position is the zero-based index of the first row that this window contains relative to the entire result set of the Cursor.

Return
Int The zero-based start position. Value is 0 or greater

getString

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

Gets the value of the field at the specified row and column index as a string.

The result is determined as follows:

  • If the field is of type Cursor#FIELD_TYPE_NULL, then the result is null.
  • If the field is of type Cursor#FIELD_TYPE_STRING, then the result is the string value.
  • If the field is of type Cursor#FIELD_TYPE_INTEGER, then the result is a string representation of the integer in decimal, obtained by formatting the value with the printf family of functions using format specifier %lld.
  • If the field is of type Cursor#FIELD_TYPE_FLOAT, then the result is a string representation of the floating-point value in decimal, obtained by formatting the value with the printf family of functions using format specifier %g.
  • If the field is of type Cursor#FIELD_TYPE_BLOB, then a SQLiteException is thrown.

Parameters
row Int: The zero-based row index. Value is 0 or greater
column Int: The zero-based column index. Value is 0 or greater
Return
String! The value of the field as a string.

getType

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

Returns the type of the field at the specified row and column index.

Parameters
row Int: The zero-based row index. Value is 0 or greater
column Int: The zero-based column index. Value is 0 or greater
Return
Int The field type. Value is android.database.Cursor#FIELD_TYPE_NULL, android.database.Cursor#FIELD_TYPE_INTEGER, android.database.Cursor#FIELD_TYPE_FLOAT, android.database.Cursor#FIELD_TYPE_STRING, or android.database.Cursor#FIELD_TYPE_BLOB

isBlob

Added in API level 1
Deprecated in API level 15
open fun isBlob(
    row: Int,
    column: Int
): Boolean

Deprecated: Use getType(int,int) instead.

Returns true if the field at the specified row and column index has type Cursor#FIELD_TYPE_BLOB or Cursor#FIELD_TYPE_NULL.

Parameters
row Int: The zero-based row index. Value is 0 or greater
column Int: The zero-based column index. Value is 0 or greater
Return
Boolean True if the field has type Cursor#FIELD_TYPE_BLOB or Cursor#FIELD_TYPE_NULL.

isFloat

Added in API level 5
Deprecated in API level 15
open fun isFloat(
    row: Int,
    column: Int
): Boolean

Deprecated: Use getType(int,int) instead.

Returns true if the field at the specified row and column index has type Cursor#FIELD_TYPE_FLOAT.

Parameters
row Int: The zero-based row index. Value is 0 or greater
column Int: The zero-based column index. Value is 0 or greater
Return
Boolean True if the field has type Cursor#FIELD_TYPE_FLOAT.

isLong

Added in API level 5
Deprecated in API level 15
open fun isLong(
    row: Int,
    column: Int
): Boolean

Deprecated: Use getType(int,int) instead.

Returns true if the field at the specified row and column index has type Cursor#FIELD_TYPE_INTEGER.

Parameters
row Int: The zero-based row index. Value is 0 or greater
column Int: The zero-based column index. Value is 0 or greater
Return
Boolean True if the field has type Cursor#FIELD_TYPE_INTEGER.

isNull

Added in API level 1
Deprecated in API level 15
open fun isNull(
    row: Int,
    column: Int
): Boolean

Deprecated: Use getType(int,int) instead.

Returns true if the field at the specified row and column index has type Cursor#FIELD_TYPE_NULL.

Parameters
row Int: The zero-based row index. Value is 0 or greater
column Int: The zero-based column index. Value is 0 or greater
Return
Boolean True if the field has type Cursor#FIELD_TYPE_NULL.

isString

Added in API level 5
Deprecated in API level 15
open fun isString(
    row: Int,
    column: Int
): Boolean

Deprecated: Use getType(int,int) instead.

Returns true if the field at the specified row and column index has type Cursor#FIELD_TYPE_STRING or Cursor#FIELD_TYPE_NULL.

Parameters
row Int: The zero-based row index. Value is 0 or greater
column Int: The zero-based column index. Value is 0 or greater
Return
Boolean True if the field has type Cursor#FIELD_TYPE_STRING or Cursor#FIELD_TYPE_NULL.

newFromParcel

Added in API level 1
open static fun newFromParcel(p: Parcel!): CursorWindow!

putBlob

Added in API level 1
open fun putBlob(
    value: ByteArray!,
    row: Int,
    column: Int
): Boolean

Copies a byte array into the field at the specified row and column index.

Parameters
value ByteArray!: The value to store.
row Int: The zero-based row index. Value is 0 or greater
column Int: The zero-based column index. Value is 0 or greater
Return
Boolean True if successful.

putDouble

Added in API level 1
open fun putDouble(
    value: Double,
    row: Int,
    column: Int
): Boolean

Puts a double-precision floating point value into the field at the specified row and column index.

Parameters
value Double: The value to store.
row Int: The zero-based row index. Value is 0 or greater
column Int: The zero-based column index. Value is 0 or greater
Return
Boolean True if successful.

putLong

Added in API level 1
open fun putLong(
    value: Long,
    row: Int,
    column: Int
): Boolean

Puts a long integer into the field at the specified row and column index.

Parameters
value Long: The value to store.
row Int: The zero-based row index. Value is 0 or greater
column Int: The zero-based column index. Value is 0 or greater
Return
Boolean True if successful.

putNull

Added in API level 1
open fun putNull(
    row: Int,
    column: Int
): Boolean

Puts a null value into the field at the specified row and column index.

Parameters
row Int: The zero-based row index. Value is 0 or greater
column Int: The zero-based column index. Value is 0 or greater
Return
Boolean True if successful.

putString

Added in API level 1
open fun putString(
    value: String!,
    row: Int,
    column: Int
): Boolean

Copies a string into the field at the specified row and column index.

Parameters
value String!: The value to store.
row Int: The zero-based row index. Value is 0 or greater
column Int: The zero-based column index. Value is 0 or greater
Return
Boolean True if successful.

setNumColumns

Added in API level 1
open fun setNumColumns(columnNum: Int): Boolean

Sets the number of columns in this window.

This method must be called before any rows are added to the window, otherwise it will fail to set the number of columns if it differs from the current number of columns.

Parameters
columnNum Int: The new number of columns. Value is 0 or greater
Return
Boolean True if successful.

setStartPosition

Added in API level 1
open fun setStartPosition(pos: Int): Unit

Sets the start position of this cursor window.

The start position is the zero-based index of the first row that this window contains relative to the entire result set of the Cursor.

Parameters
pos Int: The new zero-based start position. Value is 0 or greater

toString

Added in API level 1
open fun toString(): String
Return
String a string representation of the object.

writeToParcel

Added in API level 1
open fun writeToParcel(
    dest: Parcel,
    flags: Int
): Unit
Parameters
dest Parcel: The Parcel in which the object should be written. This value cannot be null.
flags Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES

Protected methods

finalize

Added in API level 1
protected open fun finalize(): Unit
Exceptions
java.lang.Throwable the Exception raised by this method

onAllReferencesReleased

Added in API level 1
protected open fun onAllReferencesReleased(): Unit

Properties

CREATOR

Added in API level 1
static val CREATOR: Parcelable.Creator<CursorWindow!>