我最近从Java迁移到Kotlin,并将我的应用程序代码转换为kotlin代码并发布了更改。但现在一些用户报告应用程序正在强行停止。但是我和经过测试的设备并没有面临这个问题。当我检查崩溃页面时。它显示了这个:
这是带有第1018行的DatabaseHelper类代码
fun getNotes(sqlCommand: String): MutableList<Note> {
val result = ArrayList<Note>()
val db = this.readableDatabase
Log.e(LOG, sqlCommand)
val cursor = db.rawQuery(sqlCommand, null)
try {
if (cursor!!.moveToFirst()) {
do {
val note = Note()
note.id = cursor.getLong(cursor.getColumnIndex(KEY_ID))
note.title = DataEncryption.encryptDecrypt(cursor.getString(cursor.getColumnIndex(KEY_TITLE)))
note.content = DataEncryption.encryptDecrypt(cursor.getString(cursor.getColumnIndex(KEY_CONTENT)))
note.updatedAt = Date(cursor.getLong(cursor.getColumnIndex(KEY_UPDATED_AT)))
note.color = cursor.getInt(cursor.getColumnIndex(KEY_COLOR))
note.favourite = cursor.getInt(cursor.getColumnIndex(KEY_FAVOURITE))
if (cursor.isNull(cursor.getInt(cursor.getColumnIndex(KEY_LOCKSTATUS)))) {
note.lock_status = 0
} else {
note.lock_status = cursor.getInt(cursor.getColumnIndex(KEY_LOCKSTATUS))
}
note.reminderDate = cursor.getString(cursor.getColumnIndex(KEY_REMINDER_DATE))
note.reminderTime = cursor.getString(cursor.getColumnIndex(KEY_REMINDER_TIME))
if (cursor.isNull(cursor.getInt(cursor.getColumnIndex(KEY_REMINDER_STATUS)))) {
note.reminderStatus = 0
} else {
note.reminderStatus = cursor.getInt(cursor.getColumnIndex(KEY_REMINDER_STATUS))
}
note.noteCategoryTitle = cursor.getString(cursor.getColumnIndex(KEY_CATEGORY_NOTE_TITLE))
note.noteCategoryStatus = cursor.getInt(cursor.getColumnIndex(KEY_CATEGORY_NOTE_STATUS))
note.checklist = cursor.getInt(cursor.getColumnIndex(KEY_CHECKLIST))
if (cursor.isNull(cursor.getInt(cursor.getColumnIndex(KEY_ALARM_REPEAT_STATUS)))) {
note.alarmRepeatStatus = 0
} else {
note.alarmRepeatStatus = cursor.getInt(cursor.getColumnIndex(KEY_ALARM_REPEAT_STATUS))
}
result.add(note)
} while (cursor.moveToNext())
}
} finally {
cursor?.close()
}
return result
}
有人请帮我解决一下。非常感谢帮助。