sqlite的DB更新sqlite、DB

2023-09-06 16:53:25 作者:与其苟延残喘不如纵情燃烧

有没有一种简单的方法,以在Android的更新sqlite的表? (如在建方法一行)?我有几个列一个表,主要是一列。我想通过主键在表中进行搜索,然后更新一行。

Is there an easy way to update a table in sqlite in android? (like a single line in built method) ? I have a table with few columns and primary is one column. I want to search by the primary key and then update a row in the table.

推荐答案

您可以使用 rawQuery 是这样的:

cur = mDb.rawQuery("update " + TABLE_NAME
+ " set column1=mango where id='" + _id + "'",null);

其中

where

CUR 光标 的对象 TABLE_NAME 表的名称 _id 的列名 的(唯一的例子)