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 | |
---|---|
CursorWindow(name: String!) 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 |
allocRow() Allocates a new row at the end of this cursor window. |
open Unit |
clear() 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 |
open Int | |
open Unit |
Frees the last row in this cursor window. |
open ByteArray! |
Gets the value of the field at the specified row and column index as a byte array. |
open Double |
Gets the value of the field at the specified row and column index as a |
open Float |
Gets the value of the field at the specified row and column index as a |
open Int |
Gets the value of the field at the specified row and column index as an |
open Long |
Gets the value of the field at the specified row and column index as a |
open Int |
Gets the number of rows in this window. |
open Short |
Gets the value of the field at the specified row and column index as a |
open Int |
Gets the start position of this cursor window. |
open String! |
Gets the value of the field at the specified row and column index as a string. |
open Int |
Returns the type of the field at the specified row and column index. |
open Boolean |
Returns true if the field at the specified row and column index has type |
open Boolean |
Returns true if the field at the specified row and column index has type |
open Boolean |
Returns true if the field at the specified row and column index has type |
open Boolean |
Returns true if the field at the specified row and column index has type |
open Boolean |
Returns true if the field at the specified row and column index has type |
open static CursorWindow! |
newFromParcel(p: Parcel!) |
open Boolean |
Copies a byte array into the field at the specified row and column index. |
open Boolean |
Puts a double-precision floating point value into the field at the specified row and column index. |
open Boolean |
Puts a long integer into the field at the specified row and column index. |
open Boolean |
Puts a null value into the field at the specified row and column index. |
open Boolean |
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 |
setStartPosition(pos: Int) Sets the start position of this cursor window. |
open String |
toString() |
open Unit |
writeToParcel(dest: Parcel, flags: Int) |
Protected methods | |
---|---|
open Unit |
finalize() |
open Unit |
Inherited functions | |
---|---|
Properties | |
---|---|
static Parcelable.Creator<CursorWindow!> |
Public constructors
CursorWindow
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
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
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
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
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
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 theprintf
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 theprintf
family of functions using format specifier%g
. - If the field is of type
Cursor#FIELD_TYPE_BLOB
, then aSQLiteException
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
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
open fun freeLastRow(): Unit
Frees the last row in this cursor window.
getBlob
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:
- If the field is of type
Cursor#FIELD_TYPE_NULL
, then the result isnull
. - If the field is of type
Cursor#FIELD_TYPE_BLOB
, then the result is the blob value. - If the field is of type
Cursor#FIELD_TYPE_STRING
, then the result is the array of bytes that make up the internal representation of the string value. - If the field is of type
Cursor#FIELD_TYPE_INTEGER
orCursor#FIELD_TYPE_FLOAT
, then aSQLiteException
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 | |
---|---|
ByteArray! |
The value of the field as a byte array. |
getDouble
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:
- If the field is of type
Cursor#FIELD_TYPE_NULL
, then the result is0.0
. - If the field is of type
Cursor#FIELD_TYPE_STRING
, then the result is the value obtained by parsing the string value withstrtod
. - If the field is of type
Cursor#FIELD_TYPE_INTEGER
, then the result is the integer value converted to adouble
. - If the field is of type
Cursor#FIELD_TYPE_FLOAT
, then the result is thedouble
value. - If the field is of type
Cursor#FIELD_TYPE_BLOB
, then aSQLiteException
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 | |
---|---|
Double |
The value of the field as a double . |
getFloat
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
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
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:
- If the field is of type
Cursor#FIELD_TYPE_NULL
, then the result is0L
. - If the field is of type
Cursor#FIELD_TYPE_STRING
, then the result is the value obtained by parsing the string value withstrtoll
. - If the field is of type
Cursor#FIELD_TYPE_INTEGER
, then the result is thelong
value. - If the field is of type
Cursor#FIELD_TYPE_FLOAT
, then the result is the floating-point value converted to along
. - If the field is of type
Cursor#FIELD_TYPE_BLOB
, then aSQLiteException
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 | |
---|---|
Long |
The value of the field as a long . |
getNumRows
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
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
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
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 isnull
. - 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 theprintf
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 theprintf
family of functions using format specifier%g
. - If the field is of type
Cursor#FIELD_TYPE_BLOB
, then aSQLiteException
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
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 |
isBlob
open funisBlob(
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
open funisFloat(
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
open funisLong(
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
open funisNull(
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
open funisString(
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 . |
putBlob
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
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
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
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
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
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
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
open fun toString(): String
Return | |
---|---|
String |
a string representation of the object. |
writeToParcel
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
protected open fun finalize(): Unit
Exceptions | |
---|---|
java.lang.Throwable |
the Exception raised by this method |