Package mil.nga.geopackage.db
Class SQLiteDatabaseUtils
java.lang.Object
mil.nga.geopackage.db.SQLiteDatabaseUtils
SQLite Database utilities
- Since:
- 5.1.0
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
isDatabaseHeaderValid
(SQLiteDatabase sqliteDatabase) Determine if the header of the database file is validstatic SQLiteDatabase
openDatabase
(String path, boolean writable) Open a databasestatic SQLiteDatabase
openDatabase
(String path, boolean writable, SQLiteDatabase.CursorFactory cursorFactory) Open a databasestatic SQLiteDatabase
openReadOnlyDatabase
(String path) Open a readable databasestatic SQLiteDatabase
openReadOnlyDatabase
(String path, SQLiteDatabase.CursorFactory cursorFactory) Open a readable databasestatic SQLiteDatabase
openReadWriteDatabase
(String path) Open a writable databasestatic SQLiteDatabase
openReadWriteDatabase
(String path, SQLiteDatabase.CursorFactory cursorFactory) Open a writable databasestatic SQLiteDatabase
Attempt to open a writable database, logging any errorsstatic SQLiteDatabase
openReadWriteDatabaseAttempt
(String path, SQLiteDatabase.CursorFactory cursorFactory) Attempt to open a writable database, logging any errorsstatic void
validateDatabase
(SQLiteDatabase sqliteDatabase, boolean validateHeader, boolean validateIntegrity, boolean close, boolean closeOnError) Validate the database header and integrity.static void
validateDatabaseAndClose
(SQLiteDatabase sqliteDatabase, boolean validateHeader, boolean validateIntegrity) Validate the database and close it.static void
validateDatabaseAndCloseOnError
(SQLiteDatabase sqliteDatabase, boolean validateHeader, boolean validateIntegrity) Validate the database and close when validation fails.static void
validateDatabaseHeader
(SQLiteDatabase sqliteDatabase) Validate the header of the database file to verify it is a sqlite databasestatic void
validateDatabaseIntegrity
(SQLiteDatabase sqliteDatabase) Validate the integrity of the database
-
Constructor Details
-
SQLiteDatabaseUtils
public SQLiteDatabaseUtils()
-
-
Method Details
-
openReadWriteDatabaseAttempt
Attempt to open a writable database, logging any errors- Parameters:
path
- full file path- Returns:
- database or null if unable to open as writable
-
openReadWriteDatabaseAttempt
public static SQLiteDatabase openReadWriteDatabaseAttempt(String path, SQLiteDatabase.CursorFactory cursorFactory) Attempt to open a writable database, logging any errors- Parameters:
path
- full file pathcursorFactory
- cursor factory- Returns:
- database or null if unable to open as writable
-
openReadWriteDatabase
Open a writable database- Parameters:
path
- full file path- Returns:
- database
-
openReadWriteDatabase
public static SQLiteDatabase openReadWriteDatabase(String path, SQLiteDatabase.CursorFactory cursorFactory) Open a writable database- Parameters:
path
- full file pathcursorFactory
- cursor factory- Returns:
- database
-
openReadOnlyDatabase
Open a readable database- Parameters:
path
- full file path- Returns:
- database
-
openReadOnlyDatabase
public static SQLiteDatabase openReadOnlyDatabase(String path, SQLiteDatabase.CursorFactory cursorFactory) Open a readable database- Parameters:
path
- full file pathcursorFactory
- cursor factory- Returns:
- database
-
openDatabase
Open a database- Parameters:
path
- full file pathwritable
- open as writable or read only- Returns:
- database
-
openDatabase
public static SQLiteDatabase openDatabase(String path, boolean writable, SQLiteDatabase.CursorFactory cursorFactory) Open a database- Parameters:
path
- full file pathwritable
- open as writable or read onlycursorFactory
- cursor factory- Returns:
- database
-
validateDatabaseAndCloseOnError
public static void validateDatabaseAndCloseOnError(SQLiteDatabase sqliteDatabase, boolean validateHeader, boolean validateIntegrity) Validate the database and close when validation fails. Throw an error when not valid.- Parameters:
sqliteDatabase
- databasevalidateHeader
- validate the headervalidateIntegrity
- validate the integrity
-
validateDatabaseAndClose
public static void validateDatabaseAndClose(SQLiteDatabase sqliteDatabase, boolean validateHeader, boolean validateIntegrity) Validate the database and close it. Throw an error when not valid.- Parameters:
sqliteDatabase
- databasevalidateHeader
- validate the headervalidateIntegrity
- validate the integrity
-
validateDatabase
public static void validateDatabase(SQLiteDatabase sqliteDatabase, boolean validateHeader, boolean validateIntegrity, boolean close, boolean closeOnError) Validate the database header and integrity. Throw an error when not valid.- Parameters:
sqliteDatabase
- databasevalidateHeader
- validate the headervalidateIntegrity
- validate the integrityclose
- close the database after validationcloseOnError
- close the database if validation fails
-
validateDatabaseHeader
Validate the header of the database file to verify it is a sqlite database- Parameters:
sqliteDatabase
- database
-
isDatabaseHeaderValid
Determine if the header of the database file is valid- Parameters:
sqliteDatabase
- database- Returns:
- true if valid
-
validateDatabaseIntegrity
Validate the integrity of the database- Parameters:
sqliteDatabase
- database
-