方法rawQuery()中的INSERT不起作用

mik*_*hts 0 sqlite android

我不明白为什么我要尝试使用rawQuery方法插入一些记录,例如:

db.rawQuery("INSERT INTO table (name, desc) VALUES ('Name1', 'Desc1');", null);
Run Code Online (Sandbox Code Playgroud)

但这似乎不起作用,实际上,尝试使用insert()方法可以解决所有问题:

ContentValues fields = new ContentValues();
fields.put("name", "Nome1");
fields.put("desc", "Desc1");
db.insert("table", null, fields);
Run Code Online (Sandbox Code Playgroud)

我不知道为什么会这样。

Com*_*are 5

rawQuery()用于返回结果集的SQL语句。使用execSQL()SQL语句,比如INSERT,不返回结果集。