public int update(String table,ContentValues values,String whereClause,String[] whereArgs){
  verifyDbIsOpen();
  if (values == null || values.size() == 0) {
    throw new IllegalArgumentException("Empty values");
  }
  StringBuilder sql=new StringBuilder(120);
  sql.append("UPDATE ");
  sql.append(table);
  sql.append(" SET ");
  int setValuesSize=values.size();
  int bindArgsSize=(whereArgs == null) ? setValuesSize : (setValuesSize + whereArgs.length);
  Object[] bindArgs=new Object[bindArgsSize];
  int i=0;
  for (  String colName : values.keySet()) {
    sql.append((i > 0) ? "," : "");
    sql.append(colName);
    bindArgs[i++]=values.get(colName);
    sql.append("=?");
  }
  if (whereArgs != null) {
    for (i=setValuesSize; i < bindArgsSize; i++) {
      bindArgs[i]=whereArgs[i - setValuesSize];
    }
  }
  if (!StringUtils.isEmpty(whereClause)) {
    sql.append(" WHERE ");
    sql.append(whereClause);
  }
  return executeSql(sql.toString(),bindArgs);
}

public int update ( String table , ContentValues values , String whereClause , String [ ] whereArgs ) { verifyDbIsOpen ( ) ; if ( values == null || values . size ( ) == 0 ) { throw new IllegalArgumentException ( "Empty values" ) ; } StringBuilder sql = new StringBuilder ( 120 ) ; sql . append ( "UPDATE " ) ; sql . append ( table ) ; sql . append ( " SET " ) ; int setValuesSize = values . size ( ) ; int bindArgsSize = ( whereArgs == null ) ? setValuesSize : ( setValuesSize + whereArgs . length ) ; Object [ ] bindArgs = new Object [ bindArgsSize ] ; int i = 0 ; for ( String colName : values . keySet ( ) ) { sql . append ( ( i > 0 ) ? "," : "" ) ; sql . append ( colName ) ; bindArgs [ i ++ ] = values . get ( colName ) ; sql . append ( "=?" ) ; } if ( whereArgs != null ) { for ( i = setValuesSize ; i < bindArgsSize ; i ++ ) { bindArgs [ i ] = whereArgs [ i - setValuesSize ] ; } } if ( ! StringUtils . isEmpty ( whereClause ) ) { sql . append ( " WHERE " ) ; sql . append ( whereClause ) ; } return executeSql ( sql . toString ( ) , bindArgs ) ; }
convenience method for updating rows in the database .
