【问题标题】:SQLite update item values [duplicate]SQLite 更新项目值 [重复]
【发布时间】:2017-06-03 17:22:57
【问题描述】:

在更新方法中,contentvalues 必须仅为我要更改的字段或每个字段存储值?

ContentValues contentValues = new ContentValues();
    contentValues.put("field1", new_value);
    db.update(table, contentValues, "serial code="+serial_code,null);

或

ContentValues contentValues = new ContentValues();
    contentValues.put("field1", new_value);
    contentValues.put("field2", value2);
    contentValues.put("field3", value3);
    ...
    contentValues.put("lastfield", value99);
    db.update(table, contentValues, "serial code="+serial_code,null);

【问题讨论】:

    标签: java android sqlite


    【解决方案1】:

    是的,您可以只添加要更新的列值,无需为 SQLite 内容值中的任何表传递所有列的值。

    【讨论】:

      【解决方案2】:

      只需传递已更改的列值,查找更多详细信息here

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-09-17
        • 1970-01-01
        • 2020-02-20
        • 1970-01-01
        • 2016-09-28
        • 1970-01-01
        • 1970-01-01
        • 2013-12-13
        相关资源
        最近更新 更多