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.
Here is my 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();
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
I only have 5 airports in the table right now, so I'm not going over some memory limit or anything like that.
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!
make sure the column names u are giving is correct...