Reputation: 861
I have an SQLite database where I have a table named object_zone. This table has two columns, of type integer: object and zone.
If I copy the database onto my computer, and query it with:
SELECT object FROM object_zone WHERE zone = 791
it returns several rows.
However, on my Android phone, if I query it with:
Cursor cursor = database.query( "object_zone", new String[] {"object"}, "zone = ?", new String[] { Long.toString( zoneId )}, null, null, null);
Where zoneId = 791, the cursor contains 0 rows. How have I stuffed up the usage of the query function?
Upvotes: 0
Views: 406
Reputation: 185
Maybe the problem here is the casting to string. Can you try the rawQuery method with the same sql that you executes on your computer?
Upvotes: 0
Reputation: 11522
Did you call cursor.moveToFirst()
on the returned cursor? Without having called that, cursor.getCount()
may erroneously return 0 (or perhaps it's -1...)
I've been tripped up by this a few times...
Upvotes: 1