Friday, January 20, 2012

Update method doesn"t update database with value


Here is my piece of code which runs without errors, but doesn't update database:




ContentValues cv_lio = new ContentValues();
cv_lio.put("u_lio",1);
String where = "u_name" + "=" + 5;
db.update(table_name, cv_lio,where,null);



Can anyone improve my update query to work well.

1 comment:

  1. Proceed as follow :

    ContentValues cv_lio = new ContentValues();
    cv_lio.put("u_lio",1);
    String where = "u_name" + " = ?";
    String[] whereArgs = new String[] {String.valueOf(5)};
    db.update(table_name, cv_lio, where, whereArgs);


    please refer to documentation which is, I must confess, not so clear on that precise point...

    ReplyDelete