简体   繁体   English

我无法从 kotlin 中的数据库中删除选定的 ID 数据

[英]I can't delete selected id data from database in kotlin

What should I do at this stage to delete the selected id?这个阶段我应该怎么做才能删除选中的id? I tried all the ways I could think of.我尝试了所有我能想到的方法。 thanks谢谢

val db = this.writableDatabase
db.delete(table_name, null, null)


val db = this.writableDatabase
db.delete(table_name, "$col_id=?", arrayOf(itemId.toString()) )
    Toast.makeText(context, "Silindi", Toast.LENGTH_LONG).show()
    db.close()

Try executing a delete query like this尝试执行这样的删除查询

val sql = "DELETE FROM $table_name WHERE $col_id = $itemId"
db.execSQL(sql)

Then show the Toast message to indicate that the item has been deleted, and close the database connection afterwards.然后显示 Toast 消息表明该项目已被删除,然后关闭数据库连接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 KOTLIN 我无法从 sqlite 数据库 kotlin RecyclerView 中删除数据 - KOTLIN I can't delete data from sqlite database kotlin RecyclerView Android Kotlin:如何从 Firebase 中删除数据 - Android Kotlin: How can I delete the data from Firebase 如何使用 Kotlin 中的 SQLite 数据库中的 id 和值填充微调器? - How can I populate a spinner with id and value from SQLite database in Kotlin? 我正在使用 kotlin 处理 RoomDatabase,我想删除房间数据库中的选定行 - I am working on RoomDatabase using kotlin, I want to delete the selected row in room database 如何将来自 firestore 数据库中特定集合的文档字段数据存储到 kotlin 中的字符串变量 - How can I store document field data from a particular collection in firestore database to a string variable in kotlin 如何从数据库中删除元素 realm Kotlin - How to delete element from database realm Kotlin 为什么不能直接从Kotlin中一个密封的class获取数据? - Why can't I get data directly from a sealed class in Kotlin? 从 Recyclerview + 本地数据库中删除项目 [Kotlin] - Delete an Item from the Recyclerview + Local database [Kotlin] Kotlin 无法从 Model Class 与 Putextra 发送数据 - Kotlin Can't Send Data From Model Class With Putextra 无法从编辑文本中获取数据,Android Kotlin - can't get data from edit text, Android Kotlin
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM