Android:SQLite Row更新导致Nullpointer异常

时间:2015-01-03 13:27:41

标签: java android sqlite nullpointerexception sql-update

我的SQLite Row Update方法在尝试更新值时会导致NullPointer异常。

 public void addLike(DBOps dop, String productid,String newValue,String oldValue)
 {
    try
    {
        ContentValues updatedValues = new ContentValues();
        updatedValues.put(TableInfo.LIKED, newValue); 
        String where="pid = ?";
        updatedb.update(TableInfo.TABLE_NAME,updatedValues, where, 
                                                new String[]{productid});
    }
    catch(Exception e)
    {
        Log.e("UPDATE ERROR", "Couldn't update likes!");
        Log.e("UPDATE ERROR", Log.getStackTraceString(e.getCause()
                                                      .getCause()));
    }
  }

我的表格名称为: TableInfo.TABLE_NAME 我的列名称在: TableInfo.LIKED

中说明

旧值由不同的Get方法检索。 ProductID和NewValue不为空。我检查了它们包含正确的值。我的Update方法是否正确?

0 个答案:

没有答案