我在向
Android sqlite数据库中插入多个条目时遇到问题.我这样插入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,38.890041,-77.035316" database.execsql(insertString);
我稍后用同样的数据库拉,如下:
String[] columns = new String[] { "latitude","longitude" }; Cursor cursor = db.query("coordinates",columns,"associated_route_id=5",null,null); cursor.moveToFirst(); if (cursor.getCount() == 0) // No rows in cursor
我使用db.insert(table,contentValues)使用它,但替换了插入以使事情更快.
问题是光标是空的,这使得它看起来像插入不起作用.为什么不起作用?