使用rawQuery()方法更新表不起作用

编程入门 行业动态 更新时间:2024-10-28 08:30:35
本文介绍了使用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()方法更新表不起作用

本文发布于:2023-07-10 08:34:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1089859.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不起作用   方法   rawQuery

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!