我正在尝试删除SQLite DB注释,并使用kotlin,并且渲染由recyclerview完成。但是我的删除无法完成工作,不是删除。对此很新,请帮助。
持有人类别
class MyHolder (Itemview : View):RecyclerView.ViewHolder(Itemview) {
var titleHolder: TextView = Itemview.findViewById(R.id.tv_title)
var descriptionHolder: TextView = Itemview.findViewById(R.id.tv_content)
var imgEditHolder: ImageView = Itemview.findViewById(R.id.im_edit)
var imgDeleteHolder: Button = Itemview.findViewById(R.id.im_delete)
}
Adapter Onbindervieewholder method
override fun onBindViewHolder(holder: MyHolder, position: Int) {
var Mynotes = noteLiist[position]
holder.titleHolder.text = Mynotes.nodeTitle
holder.descriptionHolder.text = Mynotes.nodeDescritption
holder.imgDeleteHolder.setOnClickListener {
View.OnClickListener {
val dbManager = SqlDBManager(this.context!!)
val selectionArgs = arrayOf(Mynotes.nodeID.toString())
dbManager.Delete("ID=?", selectionArgs)
LoadQuery("%")
}
}
}
[![db manager class][1]][1]
[1]: https://i.stack.imgur.com/D6SjZ.png
初始化数据库类后,在onClickListener上,执行以下操作:
val data = dbManager.DatabaseHelperNotes(context).writableDatabase
data.delete("table_name","where clause",null)