问题描述
我想从表中检索字段SQLite数据库。我已经验证了数据表中使用sqlite3的命令,并运行,我下了车用对我的数据库对象中引用的数据库中的调试器光标的查询。
I am trying to retrieve fields from a table in a SQLite database. I've verified that the data is in the table by using the sqlite3 command and running the query which I got out of the Cursor using the debugger against the database referenced inside my "database" object.
下面是我的code:
openForRead();
Cursor cursor = database.query(DATABASE_TABLE,
null, // All columns
null,
null,
null,
null,
"((" + latitude + " - " + KEY_LAT + ") * (" + latitude + " - " + KEY_LAT + ") + ( "
+ longitude + " - " + KEY_LONG + ") * ( " + longitude + " - "+ KEY_LONG + "))",
"10"
);
close();
这code生成一个SQL查询,如:
This code generates a SQL query such as:
SELECT * FROM airport ORDER BY ((35.9314068 - latitude) * (35.9314068 - latitude) + ( -115.09285366 - longitude) * ( -115.09285366 - longitude)) LIMIT 10
我只在表5个机场,现在,所以我不打算对一些内存限制或类似的东西。
I only have 5 airports in the table right now, so I'm not going over some memory limit or anything like that.
当我在sqlite3的运行该查询我得到的数据备份。
When I run that query in sqlite3 I get the data back.
为什么总是我的光标是空的?它是空的,即使我把一切都为空(这应该只是返回的一切..)
Why is my Cursor always empty? It's empty even if I set everything to null (which should just return everything..)
推荐答案
我是关中读取数据了光标之前的数据库连接。显然,你不能这样做。现在我知道了!
I was closing the database connection before reading the data out of the Cursor. Apparently you can't do that. Now I know!
这篇关于SQLite的光标从来没有在其领域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!