本文介绍了使用rawQuery()方法更新表不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试了以下SQLite查询:
I tried the following SQLite query:
int idServizo = 150; String whereClause = id_servizio+" = '"+idServizio+" ' "; ContentValues cv = new ContentValues(); cv.put("sync", 1); int r = dbManager.updateTable("myTable", cv, whereClause);其中sync和id_servizio字段均为整数. 方法updateTable是:
Where fields sync and id_servizio are both integer. The method updateTable is:
public int updateTable(String table, ContentValues values, String whereClause){ int r = mDb.update(table, values, whereClause, null); return r; } // mDb is SQLiteDatabase object所有这些都很好. 但是,如果我尝试使用rawQuery()方法:
All this works good. But if I try this with the rawQuery() method:
public Cursor RawQuery(String sqlQuery, String[] columns){ return mDb.rawQuery(sqlQuery, columns); }该表未更新!即使没有错误发生.
The table is not updated! even if no error occurs.
int idServizo = 150; String updateQuery ="UPDATE myTable SET sync = 1 WHERE id_servizio = "+idServizio; dbManager.RawQuery(updateQuery, null);为什么这不起作用?
推荐答案问题已解决.
developer.android/reference/android/database/sqlite/SQLiteDatabase.html
不起作用,因为rawQuery运行提供的SQL并在结果集上返回Cursor.
Can't works because rawQuery runs the provided SQL and returns a Cursor over the result set.
如果我想返回表,则必须使用rawQuery,否则请不要!
If I want to return a table I have to use rawQuery, otherwise no!
增加android/中的记录的值sqlite数据库
更多推荐
使用rawQuery()方法更新表不起作用
发布评论