Package mil.nga.geopackage.db
Class GeoPackageDatabase
java.lang.Object
mil.nga.geopackage.db.GeoPackageDatabase
- All Implemented Interfaces:
GeoPackageSQLiteDatabase
GeoPackage database wrapper around SQLiteDatabase to quote table and column names
- Since:
- 1.3.1
-
Constructor Summary
ConstructorDescriptionConstructorGeoPackageDatabase
(SQLiteDatabase db, boolean writable, GeoPackageCursorFactory cursorFactory) ConstructorGeoPackageDatabase
(SQLiteDatabase db, GeoPackageCursorFactory cursorFactory) ConstructorGeoPackageDatabase
(GeoPackageDatabase database) Copy constructor -
Method Summary
Modifier and TypeMethodDescriptionvoid
Begin a transactionvoid
close()
Close the connectioncopy()
Copy the database, maintaining the same connections but with the ability to change the active used connectionint
Delete from tablevoid
End a transaction as successful and begin a new transactionvoid
End a transaction as successfulvoid
endTransaction
(boolean successful) End a transactionvoid
Execute SQLGet the active connectionGet the Android Bindings SQLite Database connectionGet the Android SQLite Database connectionorg.sqlite.database.sqlite.SQLiteDatabase
Get the SQLite bindings database connectionGet the cursor factorygetDb()
Get the SQLite database connectionlong
insert
(String table, String nullColumnHack, ContentValues values) Insert into a tablelong
insertOrThrow
(String table, String nullColumnHack, ContentValues values) Insert into a tableboolean
Determine if currently within a transactionboolean
Is the SQLite bindings database connection writableboolean
Is SQLite Android Bindings connection enabledboolean
Is the SQLite database connection writablequery
(boolean distinct, String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy, String limit) Query the tablequery
(String table, String[] columns, String[] columnsAs, String selection, String[] selectionArgs, String groupBy, String having, String orderBy) Query the tablequery
(String table, String[] columns, String[] columnsAs, String selection, String[] selectionArgs, String groupBy, String having, String orderBy, String limit) Query the tablequery
(String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy) Query the tablequery
(String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy, String limit) Query the tableRaw queryrawQueryWithFactory
(GeoPackageCursorFactory cursorFactory, String sql, String[] selectionArgs, String editTable) Raw query with factoryboolean
setUseBindings
(boolean useBindings) Set the active SQLite connection as the bindings or standardint
update
(String table, ContentValues values, String whereClause, String[] whereArgs) Update the table
-
Constructor Details
-
GeoPackageDatabase
Constructor- Parameters:
db
- database
-
GeoPackageDatabase
Constructor- Parameters:
db
- databasecursorFactory
- cursor factory- Since:
- 3.4.0
-
GeoPackageDatabase
public GeoPackageDatabase(SQLiteDatabase db, boolean writable, GeoPackageCursorFactory cursorFactory) Constructor- Parameters:
db
- databasewritable
- writable flagcursorFactory
- cursor factory- Since:
- 3.4.0
-
GeoPackageDatabase
Copy constructor- Parameters:
database
- GeoPackage database- Since:
- 3.4.0
-
-
Method Details
-
getActive
Get the active connection- Returns:
- active connection
- Since:
- 3.4.0
-
getAndroidSQLiteDatabase
Get the Android SQLite Database connection- Returns:
- connection
- Since:
- 3.4.0
-
getAndroidBindingsSQLiteDatabase
Get the Android Bindings SQLite Database connection- Returns:
- connection
- Since:
- 3.4.0
-
getDb
Get the SQLite database connection- Returns:
- connection
-
getBindingsDb
public org.sqlite.database.sqlite.SQLiteDatabase getBindingsDb()Get the SQLite bindings database connection- Returns:
- connection
- Since:
- 3.4.0
-
isUseBindings
public boolean isUseBindings()Is SQLite Android Bindings connection enabled- Returns:
- true if using bindings
- Since:
- 3.4.0
-
getCursorFactory
Get the cursor factory- Returns:
- cusror factory
- Since:
- 4.0.0
-
isWritable
public boolean isWritable()Is the SQLite database connection writable- Returns:
- true if writable
- Since:
- 3.4.0
-
isBindingsWritable
public boolean isBindingsWritable()Is the SQLite bindings database connection writable- Returns:
- true if writable
- Since:
- 3.4.0
-
setUseBindings
public boolean setUseBindings(boolean useBindings) Set the active SQLite connection as the bindings or standard- Parameters:
useBindings
- true to use bindings connection, false for standard- Returns:
- previous bindings value
- Since:
- 3.4.0
-
copy
Copy the database, maintaining the same connections but with the ability to change the active used connection- Returns:
- database
- Since:
- 3.4.0
-
execSQL
Execute SQL- Specified by:
execSQL
in interfaceGeoPackageSQLiteDatabase
- Parameters:
sql
- sql command- Throws:
SQLException
- See Also:
-
beginTransaction
public void beginTransaction()Begin a transaction- Specified by:
beginTransaction
in interfaceGeoPackageSQLiteDatabase
-
endTransaction
public void endTransaction()End a transaction as successful- Specified by:
endTransaction
in interfaceGeoPackageSQLiteDatabase
-
endTransaction
public void endTransaction(boolean successful) End a transaction- Specified by:
endTransaction
in interfaceGeoPackageSQLiteDatabase
- Parameters:
successful
- true to commit, false to rollback
-
endAndBeginTransaction
public void endAndBeginTransaction()End a transaction as successful and begin a new transaction- Specified by:
endAndBeginTransaction
in interfaceGeoPackageSQLiteDatabase
-
inTransaction
public boolean inTransaction()Determine if currently within a transaction- Specified by:
inTransaction
in interfaceGeoPackageSQLiteDatabase
- Returns:
- true if in transaction
-
delete
Delete from table- Specified by:
delete
in interfaceGeoPackageSQLiteDatabase
- Parameters:
table
- table namewhereClause
- where clausewhereArgs
- where arguments- Returns:
- deleted rows
- See Also:
-
rawQuery
Raw query- Specified by:
rawQuery
in interfaceGeoPackageSQLiteDatabase
- Parameters:
sql
- sql commandselectionArgs
- selection arguments- Returns:
- cursor
- See Also:
-
rawQueryWithFactory
public Cursor rawQueryWithFactory(GeoPackageCursorFactory cursorFactory, String sql, String[] selectionArgs, String editTable) Raw query with factory- Specified by:
rawQueryWithFactory
in interfaceGeoPackageSQLiteDatabase
- Parameters:
cursorFactory
- cursor factorysql
- sql commandselectionArgs
- selection argumentseditTable
- edit table name- Returns:
- cursor
- See Also:
-
close
public void close()Close the connection- Specified by:
close
in interfaceGeoPackageSQLiteDatabase
- See Also:
-
query
public Cursor query(String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy) Query the table- Specified by:
query
in interfaceGeoPackageSQLiteDatabase
- Parameters:
table
- table namecolumns
- columnsselection
- selectionselectionArgs
- selection argumentsgroupBy
- group byhaving
- havingorderBy
- order by- Returns:
- cursor
- See Also:
-
query
public Cursor query(String table, String[] columns, String[] columnsAs, String selection, String[] selectionArgs, String groupBy, String having, String orderBy) Query the table- Specified by:
query
in interfaceGeoPackageSQLiteDatabase
- Parameters:
table
- table namecolumns
- columnscolumnsAs
- columns asselection
- selectionselectionArgs
- selection argumentsgroupBy
- group byhaving
- havingorderBy
- order by- Returns:
- cursor
- See Also:
-
query
public Cursor query(String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy, String limit) Query the table- Specified by:
query
in interfaceGeoPackageSQLiteDatabase
- Parameters:
table
- table namecolumns
- columnsselection
- selectionselectionArgs
- selection argumentsgroupBy
- group byhaving
- havingorderBy
- order bylimit
- limit- Returns:
- cursor
- See Also:
-
query
public Cursor query(String table, String[] columns, String[] columnsAs, String selection, String[] selectionArgs, String groupBy, String having, String orderBy, String limit) Query the table- Specified by:
query
in interfaceGeoPackageSQLiteDatabase
- Parameters:
table
- table namecolumns
- columnscolumnsAs
- columns asselection
- selectionselectionArgs
- selection argumentsgroupBy
- group byhaving
- havingorderBy
- order bylimit
- limit- Returns:
- cursor
- See Also:
-
query
public Cursor query(boolean distinct, String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy, String limit) Query the table- Specified by:
query
in interfaceGeoPackageSQLiteDatabase
- Parameters:
distinct
- distinct flagtable
- table namecolumns
- columnsselection
- selectionselectionArgs
- selection argumentsgroupBy
- group byhaving
- havingorderBy
- order bylimit
- limit- Returns:
- cursor
- See Also:
-
update
Update the table- Specified by:
update
in interfaceGeoPackageSQLiteDatabase
- Parameters:
table
- table namevalues
- content valueswhereClause
- where clausewhereArgs
- where arguments- Returns:
- updated rows
- See Also:
-
insertOrThrow
public long insertOrThrow(String table, String nullColumnHack, ContentValues values) throws SQLException Insert into a table- Specified by:
insertOrThrow
in interfaceGeoPackageSQLiteDatabase
- Parameters:
table
- table namenullColumnHack
- null column hackvalues
- content values- Returns:
- row id
- Throws:
SQLException
- See Also:
-
insert
Insert into a table- Specified by:
insert
in interfaceGeoPackageSQLiteDatabase
- Parameters:
table
- table namenullColumnHack
- null column hackvalues
- content values- Returns:
- row id
- See Also:
-