samedi 3 janvier 2015

Android: SQLite Row update causes Nullpointer Exception [duplicate]


This question already has an answer here:




My SQLite Row Update method causes a NullPointer Exception when trying to update a value.



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()));
}
}


My table name is stated in: TableInfo.TABLE_NAME My column name is stated in: TableInfo.LIKED


Old value is retrieved by a different Get Method. The ProductID and the NewValue is not null. I checked and they contain the proper values. Is my Update method correct?


Aucun commentaire:

Enregistrer un commentaire