通过文件名从 sqlite 数据库中删除行且不知道特定列
是否有一种查询形式,我可以仅通过文件名从 sqlite 数据库中删除条目,而无需知道它所在的确切列。
我知道这段代码可以工作,但我不知道要为我的Where 子句添加什么。我试过这个,但我不知道是否正确。谢谢。
public boolean deleteTag(String entry ){
return db.delete(DATABASE_TABLE, KEY_ID + "=?", new String[]{entry}) >0;
}
或者无论如何,我可以通过查询游标来检索列名。抱歉,我知道我问的问题听起来很奇怪。谢谢
is there a form of query which i can delete an entry from an sqlite database by just its file name without knowing the exact column it resides on.
i know this code could work, but i don't know what to put for my Where clause. i tried this but i don't know if am correct. Thank you.
public boolean deleteTag(String entry ){
return db.delete(DATABASE_TABLE, KEY_ID + "=?", new String[]{entry}) >0;
}
or is there anyway, i can retrieve the column name from querying a cursor.sorry i know what am asking sounds strange. Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
'Cursor.getColumnNames()
将为您提供名称数组。然后你可以循环遍历它并通过执行
Cursor.getColumnIndex(columnName)` 来获取列 id,这就是你要问的吗?'Cursor.getColumnNames()
will give you array of names. Then you can loop through it and get column id by doing
Cursor.getColumnIndex(columnName)` is that what you are asking?