Class SQLiteDatabaseUtils

java.lang.Object
mil.nga.geopackage.db.SQLiteDatabaseUtils

public class SQLiteDatabaseUtils extends Object
SQLite Database utilities
Since:
5.1.0
  • Constructor Details

    • SQLiteDatabaseUtils

      public SQLiteDatabaseUtils()
  • Method Details

    • openReadWriteDatabaseAttempt

      public static SQLiteDatabase openReadWriteDatabaseAttempt(String path)
      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 path
      cursorFactory - cursor factory
      Returns:
      database or null if unable to open as writable
    • openReadWriteDatabase

      public static SQLiteDatabase openReadWriteDatabase(String path)
      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 path
      cursorFactory - cursor factory
      Returns:
      database
    • openReadOnlyDatabase

      public static SQLiteDatabase openReadOnlyDatabase(String path)
      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 path
      cursorFactory - cursor factory
      Returns:
      database
    • openDatabase

      public static SQLiteDatabase openDatabase(String path, boolean writable)
      Open a database
      Parameters:
      path - full file path
      writable - 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 path
      writable - open as writable or read only
      cursorFactory - 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 - database
      validateHeader - validate the header
      validateIntegrity - 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 - database
      validateHeader - validate the header
      validateIntegrity - 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 - database
      validateHeader - validate the header
      validateIntegrity - validate the integrity
      close - close the database after validation
      closeOnError - close the database if validation fails
    • validateDatabaseHeader

      public static void validateDatabaseHeader(SQLiteDatabase sqliteDatabase)
      Validate the header of the database file to verify it is a sqlite database
      Parameters:
      sqliteDatabase - database
    • isDatabaseHeaderValid

      public static boolean isDatabaseHeaderValid(SQLiteDatabase sqliteDatabase)
      Determine if the header of the database file is valid
      Parameters:
      sqliteDatabase - database
      Returns:
      true if valid
    • validateDatabaseIntegrity

      public static void validateDatabaseIntegrity(SQLiteDatabase sqliteDatabase)
      Validate the integrity of the database
      Parameters:
      sqliteDatabase - database