Android 数据库多选
我在让光标返回带有选择字符串的查询时遇到这个问题。 下面是游标的示例结构:
String T_NAME = "tableName";
String T_ID = "idTable";
String C_FIRST = "first";
String C_SECOND = "second";
Cursor cursor = database.query(T_NAME, null, C_FIRST + " = ? AND " + C_SECOND + " = ?", new String[] { String.valueOf(firstArr), String.valueOf(secondArr) } , null, null, T_ID);
当我检查cursor.getCount()时,它返回0,但是当使用SQLite数据库浏览器检查表并使用下面的SQL命令时,它返回正确的数据。
SELECT * FROM tableName WHERE first = 0 AND second = 0
错误原因可能是什么以及如何解决?
提前致谢。
I have this problem in getting my cursor return my query with a selection String.
Below is the sample structure of the cursor :
String T_NAME = "tableName";
String T_ID = "idTable";
String C_FIRST = "first";
String C_SECOND = "second";
Cursor cursor = database.query(T_NAME, null, C_FIRST + " = ? AND " + C_SECOND + " = ?", new String[] { String.valueOf(firstArr), String.valueOf(secondArr) } , null, null, T_ID);
When I check the cursor.getCount() it return 0 but when check the table using SQLite Database Browser and with the SQL command below it return the proper data.
SELECT * FROM tableName WHERE first = 0 AND second = 0
What could be the cause of error and how can I resolve it?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的代码对我来说看起来不错。您确定使用 SQLite 数据库浏览器查询的 SQLite 数据库与您的应用程序访问的 SQLite 数据库是同一数据库吗?
使用 adb 远程 shell 直接连接到设备上的数据库文件并在那里发出选择查询。例子:
Your code looks fine to me. Are you sure the SQLite database you are querying with SQLite Database Browser is the same one that is being accessed by your application?
Use an adb remote shell to connect to the database file on the device directly and issue your select query there. Example: