Closed caarmen closed 6 years ago
Cursor
extends Closeable
starting from jellybean.
time to change the minsdk
So to support older Android versions I have to use .use { ... }
only from Jellybean?
val cursor = ...
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
cursor.use {
while (it.moveToNext()) {
//
}
}
} else {
while (cursor.moveToNext()) {
//
}
cursor.close()
}
Something like this?
I have users running Android 4.0.3-4.0.4 and Crashlytics (or Google Console) for some of these devices reports the next exception in funcitons where I use Cursor
and SQLiteOpenHelper
Caused by java.lang.ClassCastException
cannot be cast to java.io.Closeable
https://stackoverflow.com/questions/39430179/kotlin-closable-and-sqlitedatabase-on-android