Android:如何在数据库中使用游标?
我正在尝试使用光标从记录中返回字段名称。下面的语句是否返回一个表的所有记录?
Cursor u = db.query(t1, new String[] { "id","titlee","date", "tme", "detail","selcal","partmail","stat","prior" },null, null, null, null, null);
非常感谢任何帮助。
I'm trying to return a field name from a record using cursor. Does the statement as follows returns all the records of a table?
Cursor u = db.query(t1, new String[] { "id","titlee","date", "tme", "detail","selcal","partmail","stat","prior" },null, null, null, null, null);
Any help is highly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
或
两者相同。
更新
这个答案很好地解释了如何使用where或选择查询。
or
Both are same.
UPDATE
This answer explains nicely how you can use the where or selection query.
由于没有 WHERE 子句,因此将返回所有行。游标的每个项目将准确包含您在数组中列出的字段(假设这些列存在于表中)。但是,如果您只对一个字段感兴趣(您说“字段名称”),那么您最好在查询中仅包含该列 ID。因此,假设您只真正关心“titlee”列,那么您的查询可能是:
Cursor u = db.query(t1, new String[] { "titlee" }, null, null, null, null,空);
As you have no WHERE clause, all rows will be returned. Each item of the cursor will contain exactly those fields you list in the array (assuming those columns exist in the table). However, if you are only interested in one field (you say "a field name") then you'd be better including only that column id in the query. So, assuming you only really care about the column "titlee", then your query could be:
Cursor u = db.query(t1, new String[] { "titlee" }, null, null, null, null, null);