我想插入一些排在Android的一个表,我使用的是这样的:
I wanna insert some row to a table in Android, I'm using this:
INSERT INTO MyTable (Column_1, Column_1) VALUES ('X',100);
在查询运行没有异常被抛出,但是当我检索 MyTable的
中的所有行,没有行被返回。
The query runs and no exception is thrown, but when I retrieve all rows from MyTable
, no row
is returned.
我不想使用插入
方法,因为查询是从文件中读取,我想将它们插入到数据库中。
I do not want to use the insert
method, because the queries are read from a file and I want to insert them to the database.
这有什么错我的code?
What's wrong with my code?
更新:在 rawQuery()
方法不会运行查询,但 execSQL()
一样。
Update : The rawQuery()
method doesn't run the query, but execSQL()
does.
推荐答案
你的问题的标题建议你使用 rawQuery()
。它只是编译SQL,但不运行它。呼吁的的moveTo ...()
方法之一返回光标
也将执行SQL。
The title of your question suggests you're using rawQuery()
. It just compiles the SQL but does not run it. Calling one of the moveTo...()
methods on the returned Cursor
would also execute the SQL.
有关插入查询,使用 execSQL()
而不是 rawQuery()
,即使文档不正确各州它不应与使用插入
。
For an insert query, use execSQL()
instead of rawQuery()
, even if the documentation incorrectly states it should not be used with INSERT
.
相关推荐
最新文章