-
public class SqliteOrgDatabaseUtil
-
-
Field Summary
Fields Modifier and Type Field Description public final static SqliteOrgDatabaseUtilINSTANCE
-
Method Summary
Modifier and Type Method Description final BooleanvalidateDatabaseFile(String path, String databaseNameTag, String tableDataCountCheck, Boolean allowZeroCount)Preform a PRAGMA check on the database and optionally check a table for existing data. final BooleanalterTableIfColumnDoesNotExist(SQLiteDatabase database, String tableName, String columnName, String alterSql)Check to see if a column in a database exists, if it does not... final BooleantableExists(SQLiteDatabase database, String tableName)Check to see if a table in a database exists final BooleancolumnExists(SQLiteDatabase database, String tableName, String columnName)Check to see if a column in a database exists final UnitresetRoom(SQLiteDatabase database, Integer newVersion)Remove the room master table and set the database version (default 0) final UnitcheckAndFixRoomIdentityHash(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 StringfindRoomIdentityHash(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 BooleandeleteDatabaseFiles(File file)Deletes a database including its journal file and other auxiliary files that may have been created by the database engine. -
-
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 databasedatabaseNameTag- Optional tag name to help identify database in loggingtableDataCountCheck- 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 databasetableName- table for columnNamecolumnName- column to from tableName to be checkedalterSql- 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 databasetableName- 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 databasetableName- table for columnNamecolumnName- 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 DatabasenewVersion- 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 DatabaseexpectedVersion- 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.
-
-
-
-