首页 文章

在Android上使用SQLite时,我必须使用execSQL进行更新吗?

提问于
浏览
1

所以我的问题是这个 .

In the existing android framework is there any way to perform an UPDATE where the SET value is an expression using ContentValues?

现在我想要实现的是SQL更新,其中一列更新为其他两列的值,如下所示:

UPDATE myTable SET columnA = columnB + columnC WHERE rowId = 5

这个工作,没问题 . 但是我无法通过ContentValues和android文档explicitly says看到这样做的任何方式:

void execSQL(String sql,Object [] bindArgs)执行一个不是SELECT / INSERT / UPDATE / DELETE的SQL语句 . ...对于UPDATE语句,请改用以下任何一种语句 . update(String,ContentValues,String,String [])updateWithOnConflict(String,ContentValues,String,String [],int)

那么可以用现有的更新方法来完成,还是我将不得不忽略文档并继续使用execSQL?

1 回答

相关问题