Package 

Object SqliteOrgDatabaseUtil

    • Method Summary

      Modifier and Type Method Description
      final Boolean validateDatabaseFile(String path, String databaseNameTag, String tableDataCountCheck, Boolean allowZeroCount) Preform a PRAGMA check on the database and optionally check a table for existing data.
      final Boolean alterTableIfColumnDoesNotExist(SQLiteDatabase database, String tableName, String columnName, String alterSql) Check to see if a column in a database exists, if it does not...
      final Boolean tableExists(SQLiteDatabase database, String tableName) Check to see if a table in a database exists
      final Boolean columnExists(SQLiteDatabase database, String tableName, String columnName) Check to see if a column in a database exists
      final Unit resetRoom(SQLiteDatabase database, Integer newVersion) Remove the room master table and set the database version (default 0)
      final Unit checkAndFixRoomIdentityHash(SQLiteDatabase database, Integer expectedVersion, String expectedIdentityHash) If the database should NOT have a migration and is a pre-populated database that should not be managed by Room...
      final String findRoomIdentityHash(SQLiteDatabase database) Find the Room Identity Hash Note: if you are not sure if the room_master_table exists, check first with tableExists(database, "room_master_table")
      final Boolean deleteDatabaseFiles(File file) Deletes a database including its journal file and other auxiliary files that may have been created by the database engine.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • validateDatabaseFile

         final Boolean validateDatabaseFile(String path, String databaseNameTag, String tableDataCountCheck, Boolean allowZeroCount)

        Preform a PRAGMA check on the database and optionally check a table for existing data. This check can be used to check a database prior to hooking it up to Room and running database table upgrades and versioning (useful for pre-existing databases)

        NOTE: This call will use the org.sqlite.database.sqlite.SQLiteDatabase Library... see also DatabaseUtil.validateDatabaseFile(...)

        Parameters:
        path - File path to database
        databaseNameTag - Optional tag name to help identify database in logging
        tableDataCountCheck - Optional check on a table for data.
        allowZeroCount - Optional tableDataCountCheck if false return false if count is zero
      • alterTableIfColumnDoesNotExist

         final Boolean alterTableIfColumnDoesNotExist(SQLiteDatabase database, String tableName, String columnName, String alterSql)

        Check to see if a column in a database exists, if it does not... alter query will be run

        Parameters:
        database - Sqlite database
        tableName - table for columnName
        columnName - column to from tableName to be checked
        alterSql - SQL to be run if the column does not exits.
      • tableExists

         final Boolean tableExists(SQLiteDatabase database, String tableName)

        Check to see if a table in a database exists

        Parameters:
        database - Sqlite database
        tableName - tableName to from database to be checked
      • columnExists

         final Boolean columnExists(SQLiteDatabase database, String tableName, String columnName)

        Check to see if a column in a database exists

        Parameters:
        database - Sqlite database
        tableName - table for columnName
        columnName - column to from tableName to be checked
      • resetRoom

         final Unit resetRoom(SQLiteDatabase database, Integer newVersion)

        Remove the room master table and set the database version (default 0)

        Parameters:
        database - SQLite Database
        newVersion - version to be set on database (default to 0)
      • checkAndFixRoomIdentityHash

         final Unit checkAndFixRoomIdentityHash(SQLiteDatabase database, Integer expectedVersion, String expectedIdentityHash)

        If the database should NOT have a migration and is a pre-populated database that should not be managed by Room... make sure Room migration is never needed.

        Parameters:
        database - SQLite Database
        expectedVersion - SQLite Database version (PRAGMA user_version)
        expectedIdentityHash - Hash that is expected.
      • findRoomIdentityHash

         final String findRoomIdentityHash(SQLiteDatabase database)

        Find the Room Identity Hash Note: if you are not sure if the room_master_table exists, check first with tableExists(database, "room_master_table")

        Parameters:
        database - SQLite Database
      • deleteDatabaseFiles

         final Boolean deleteDatabaseFiles(File file)

        Deletes a database including its journal file and other auxiliary files that may have been created by the database engine.

        Parameters:
        file - The database file path.