我的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方法是否正确?