【问题标题】:Android SQLite update statementAndroid SQLite 更新语句
【发布时间】:2014-09-17 21:21:14
【问题描述】:

我正在尝试更新单行中的单个属性。但是,我下面的代码正在使用“新描述”的值更新每一行。

public void editSingleLocation(String id, String new_description){
        SQLiteDatabase db = this.getWritableDatabase();
         ContentValues newValues = new ContentValues();
         newValues.put(COLUMN_DESCRIPTION, new_description);
         db.update(TABLE_LOCATIONS, newValues, KEY_ID=id, null);

我试图使用此链接中的解决方案之一Android SQLite: Update Statement

但它似乎不起作用。

【问题讨论】:

    标签: android sqlite sql-update


    【解决方案1】:

    修复它:

    问题在于“KEY_ID=id”;它需要更改为:

     db.update(TABLE_LOCATIONS, newValues, KEY_ID+"="+id, null);
    

    【讨论】:

    • 对不起,我的错。它看起来像是属于问题的信息(在您编辑之前更是如此)。
    猜你喜欢
    • 2011-08-24
    • 1970-01-01
    • 1970-01-01
    • 2015-02-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-29
    • 2011-12-13
    相关资源
    最近更新 更多