我正在尝试使用rawQuery和execsql方法来操作我的数据库,而不是.update,.insert等.我正在尝试使用以下代码执行更新:
db.execsql("UPDATE configuration " +
"SET number_fields = " + number_fields + ","
+ "frequency = " + frequency + ","
+ "ag = " + ag + ","
+ "number_alarms = " + number_alarms + ","
+ "Failed_rapper = " + Failed_rapper + ","
+ "max_mv = " + max_mv + ","
+ "max_nav = " + max_nav + " "
+ "WHERE serial_id = " + Integer.toString(id) + ";");
在此操作之后,有一个日志表明发生了更新并且它似乎正常工作,但是当我尝试在表上执行select语句时,它返回时出现以下错误:
06-10 10:01:47.564: W/System.err(3815): android.database.CursorIndexOutOfBoundsException: Index 0 requested,with a size of 0
现在我在Android中使用sqlite数据库浏览器手动插入的不同数据上执行了相同的SELECT,它运行正常.我也在sqlite浏览器中执行了相同的UPADTE,它在那里工作.因此我知道问题是在Android上运行时UPDATE命令不起作用.
问题:为什么UPDATE命令在execsql()方法中不起作用?