Pro Android with Kotlin
CHAPTER 6: Content Providers
Download 5.42 Mb. Pdf ko'rish
|
@de android telegram Pro Android with Kotlin Developing Modern Mobile
74
CHAPTER 6: Content Providers override fun getInt(column: Int): Int This gets a long value (the column index is zero based). override fun getLong(column: Int): Long This gets a long value (the column index is zero based). override fun getShort(column: Int): Short This gets a short value (the column index is zero based). override fun getFloat(column: Int): Float This gets a float value (the column index is zero based). override fun getDouble(column: Int): Double This gets a double value (the column index is zero based). override fun getString(column: Int): String This gets a string value (the column index is zero based). override fun isNull(column: Int): Boolean This tells whether the value is null (the column index is zero based). override fun getType(column: Int): Int You don’t have to overwrite this, but if you don’t, it will always return Cursor.FIELD_TYPE_STRING, assuming that getString() will always return something meaningful. For more fine-grained control, let it return one of FIELD_TYPE_NULL, FIELD_TYPE_INTEGER, FIELD_TYPE_FLOAT, FIELD_TYPE_ STRING, or FIELD_TYPE_BLOB. The column index is zero based. override fun getBlob(column: Int): ByteArray Overwrite this, if you want to support blobs. Otherwise, an UnsupportedOperationException will be thrown. override fun onMove(oldPosition: Int, newPosition: Int): Boolean Although not marked as abstract, you must overwrite this. Your implementation must move the cursor to the corresponding position in the result set. Possible values range from -1 (before the first position; not a valid position) to count (after the last position; not a valid position). Let it return true if the move was successful. If you don’t overwrite it, nothing will happen, and the function returns always true. AbstractCursor also provides a method called fillWindow(position: Int, window: CursorWindow?): Unit that you can use to fill an android.database.CursorWindow object based on the result set from the query. See the online API documentation of CursorWindow to proceed with this approach. Besides AbstractCursor, the Cursor interface has a couple more (abstract) implementations you can use, as summarized in Table 6-2 . |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling