code: public static long insertOrThrow(Connection connection, String table,
  			ContentValues values) {
  
  		StringBuilder insert = new StringBuilder();
  		insert.append("insert into ").append(CoreSQLUtils.quoteWrap(table))
  				.append("(");
  
  		Object[] args = null;
  		int size = (values != null && values.size() > 0) ? values.size() : 0;
  
  		args = new Object[size];
  		int i = 0;
  		for (String colName : values.keySet()) {
  			insert.append((i > 0) ? "," : "");
  			insert.append(CoreSQLUtils.quoteWrap(colName));
  			args[i++] = values.get(colName);
  		}
  		insert.append(')');
  		insert.append(" values (");
  		for (i = 0; i < size; i++) {
  			insert.append((i > 0) ? ",?" : "?");
  		}
  		insert.append(')');
  
  		String sql = insert.toString();
  
  		PreparedStatement statement = null;
  
  		long id = 0;
  		try {
  			statement = connection.prepareStatement(sql);
  			setArguments(statement, args);
  			int count = statement.executeUpdate();
  
  			if (count == 0) {
  				throw new GeoPackageException(
  						"Failed to execute SQL insert statement: " + sql
  								+ ". No rows added from execution.");
  			}
  
  			try (ResultSet generatedKeys = statement.getGeneratedKeys()) {
  				if (generatedKeys.next()) {
  					id = generatedKeys.getLong(1);
  				} else {
  					throw new GeoPackageException(
  							"Failed to execute SQL insert statement: " + sql
  									+ ". No row id was found.");
  				}
  			}
  		} catch (SQLException e) {
  			throw new GeoPackageException(
  					"Failed to execute SQL insert statement: " + sql, e);
  		} finally {
  			closeStatement(statement, sql);
  		}
  
  		return id;
  	}
docs: Insert a new row
  
  @param connection
  connection
  @param table
  table name
  @param values
  content values
  @return row id