public long insert(String table,String nullColumnHack,ContentValues values){
  verifyDbIsOpen();
  StringBuilder sql=new StringBuilder();
  sql.append("INSERT");
  sql.append(" INTO ");
  sql.append(table);
  sql.append(" (");
  Object[] bindArgs=null;
  int size=(values != null && values.size() > 0) ? values.size() : 0;
  if (size > 0) {
    bindArgs=new Object[size];
    int i=0;
    for (    String colName : values.keySet()) {
      sql.append((i > 0) ? "," : "");
      sql.append(colName);
      bindArgs[i++]=values.get(colName);
    }
    sql.append(')');
    sql.append(" VALUES (");
    for (i=0; i < size; i++) {
      sql.append((i > 0) ? ",?" : "?");
    }
  }
 else {
    sql.append(nullColumnHack + ") VALUES (NULL");
  }
  sql.append(')');
  return executeSql(sql.toString(),bindArgs);
}

public long insert ( String table , String nullColumnHack , ContentValues values ) { verifyDbIsOpen ( ) ; StringBuilder sql = new StringBuilder ( ) ; sql . append ( "INSERT" ) ; sql . append ( " INTO " ) ; sql . append ( table ) ; sql . append ( " (" ) ; Object [ ] bindArgs = null ; int size = ( values != null && values . size ( ) > 0 ) ? values . size ( ) : 0 ; if ( size > 0 ) { bindArgs = new Object [ size ] ; int i = 0 ; for ( String colName : values . keySet ( ) ) { sql . append ( ( i > 0 ) ? "," : "" ) ; sql . append ( colName ) ; bindArgs [ i ++ ] = values . get ( colName ) ; } sql . append ( ')' ) ; sql . append ( " VALUES (" ) ; for ( i = 0 ; i < size ; i ++ ) { sql . append ( ( i > 0 ) ? ",?" : "?" ) ; } } else { sql . append ( nullColumnHack + ") VALUES (NULL" ) ; } sql . append ( ')' ) ; return executeSql ( sql . toString ( ) , bindArgs ) ; }
convenience method for inserting a row into the database .
