I am having a problem inserting multiple entries into an Android SQLite database. I insert like so with db.execQuery():
String insertString = "INSERT INTO coordinates
SELECT 0 AS _id, 5 AS associated_route_id, 38.88945 AS latidude, -77.034821 AS longitude
UNION SELECT 1, 5, 38.889671, -77.034912
UNION SELECT 2, 5, 38.890041, -77.035316"
database.execSQL(insertString);
I pull later with the same db like so:
String[] columns = new String[] { "latitude", "longitude" };
Cursor cursor = db.query("coordinates", columns,
"associated_route_id=5", null, null, null,
null);
cursor.moveToFirst();
if (cursor.getCount() == 0)
// No rows in cursor
I got this to work using db.insert(table, null, contentValues), but replaced the insert to make things faster.
The problem is that the cursor is empty which makes it seem like the insert is not working. Why doesn't it work?