2015-04-12 31 views
0

我不明白爲什麼我試圖插入使用方法rawQuery一些記錄,例如:INSERT的方法rawQuery()不工作

db.rawQuery("INSERT INTO table (name, desc) VALUES ('Name1', 'Desc1');", null); 

但是,這似乎並沒有工作,事實上,嘗試使用insert()方法全部工作:

ContentValues fields = new ContentValues(); 
fields.put("name", "Nome1"); 
fields.put("desc", "Desc1"); 
db.insert("table", null, fields); 

我想知道爲什麼會這樣。

回答

3

rawQuery()適用於返回結果集的SQL語句。對於SQL語句使用execSQL(),如INSERT,它們不返回結果集。

+0

非常感謝你的幫助! –