FeatureDao provides typed read and write access to a single feature table inside a GeoPackage. Obtain one from an open GeoPackage — do not construct it directly.
FeatureDao extends UserDao, so all generic query helpers from UserDao are also available on a FeatureDao.Creating a FeatureDao
getFeatureDao()
Call this on an openGeoPackage to get a FeatureDao for the named table.
Querying rows
queryForAll()
Returns aFeatureResultSet containing every row in the table. Iterate the result set and close it when done.
queryForId()
Returns aFeatureResultSet filtered to the single row with the given primary key.
Primary key value of the row to retrieve.
queryForIdRow()
Convenience wrapper aroundqueryForId() that returns the first matching FeatureRow directly, or null if not found.
Primary key value of the row to retrieve.
queryForFieldValues()
Returns aFeatureResultSet for all rows where each field in fieldValues matches.
A
FieldValues map of column name to expected value.query()
Returns aFeatureResultSet using an optional raw SQL WHERE clause and bind arguments.
SQL
WHERE clause, without the WHERE keyword. Omit to return all rows.Bind arguments that replace
? placeholders in where.Counting rows
count()
Returns the total number of rows, optionally filtered by aWHERE clause.
getCount()
An alternative count helper that accepts the same optionalWHERE clause parameters.
Writing rows
newRow()
Creates and returns a blankFeatureRow backed by this table’s schema. Populate the row then pass it to create().
create()
Inserts a new row into the table and returns the new row’s id.A
FeatureRow obtained from newRow() with geometry and attribute values set.The primary key id of the newly inserted row.
update()
Updates an existing row in the table. Matches by the row’s primary key.The modified
FeatureRow to persist. The row’s getId() must match an existing record.Number of rows updated (should be
1 on success).deleteRow()
Deletes the row represented by the givenFeatureRow.
The row to delete. Uses the row’s
getId() to locate the record.deleteById()
Deletes the row with the specified primary key.Primary key of the row to delete.
Number of rows deleted (should be
0 or 1).Table metadata
getTable()
Returns the underlyingFeatureTable schema object describing the table’s columns.
getGeometryColumnName()
Returns the name of the geometry column in this feature table.getGeometryType()
Returns theGeometryType enum value declared for this table’s geometry column.
FeatureRow
AFeatureRow represents a single row from a feature table. Each row holds geometry data and zero or more attribute columns.
getGeometry()
Returns theGeoPackageGeometryData wrapper containing the encoded geometry, or null if the geometry column is empty.
setGeometry()
Sets the geometry column value for this row.A
GeoPackageGeometryData wrapping the geometry to store.getGeometryValue()
Convenience method — returns the decodedGeometry object directly from the geometry column, or null.
getValue()
Returns the value of the named column for this row.Name of the column to read.
setValue()
Sets the value of the named column for this row.Name of the column to write.
Value to assign. Must be compatible with the column’s declared data type.
getId()
Returns the primary key value of this row.The integer primary key for this row.