Search code examples
androidkotlinandroid-ktx

Can't find `fun Cursor.getString(columnName: String): String` implementation


Where to these functions implemented?

https://android.github.io/android-ktx/core-ktx/androidx.database/android.database.-cursor/index.html

I saw package androidx.core.database but can't find implementation. There are only the functions like these.

inline fun Cursor.getBlobOrNull(index: Int) = if (isNull(index)) null else getBlob(index)
inline fun Cursor.getDoubleOrNull(index: Int) = if (isNull(index)) null else getDouble(index)
inline fun Cursor.getFloatOrNull(index: Int) = if (isNull(index)) null else getFloat(index)
inline fun Cursor.getIntOrNull(index: Int) = if (isNull(index)) null else getInt(index)
inline fun Cursor.getLongOrNull(index: Int) = if (isNull(index)) null else getLong(index)
inline fun Cursor.getShortOrNull(index: Int) = if (isNull(index)) null else getShort(index)
inline fun Cursor.getStringOrNull(index: Int) = if (isNull(index)) null else getString(index)

Solution

  • The name-based extensions for Cursor have been removed by Jake Wharton.

    In his words:

    They encourage a pattern of inefficiency. You should look up the column names once prior to iteration or use a higher-level abstraction like Room or SQL Delight which does that for you.

    You can find the full git history for this package here: https://android.googlesource.com/platform/frameworks/support/+log/android-room-release/core/ktx/src/main/java/androidx/core/database