public class SQLDatabaseFactory
extends java.lang.Object
SQLDatabase
, and update schemaConstructor and Description |
---|
SQLDatabaseFactory() |
Modifier and Type | Method and Description |
---|---|
static SQLDatabase |
createSQLDatabase(java.lang.String dbFilename,
KeyProvider provider)
SQLCipher-based implementation for creating database.
|
static SQLDatabase |
openSqlDatabase(java.lang.String dbFilename,
KeyProvider provider)
SQLCipher-based implementation for opening database.
|
static void |
updateSchema(SQLDatabase database,
Migration migration,
int version)
Update schema for
SQLDatabase |
public static SQLDatabase createSQLDatabase(java.lang.String dbFilename, KeyProvider provider) throws java.io.IOException, java.sql.SQLException
dbFilename
- full file path of the db fileprovider
- Key provider object storing the SQLCipher key
Supply a NullKeyProvider to use a non-encrypted database.SQLDatabase
for the given filenamejava.io.IOException
- if the file does not exists, and also
can not be createdjava.sql.SQLException
- if the database cannot be opened.public static SQLDatabase openSqlDatabase(java.lang.String dbFilename, KeyProvider provider) throws java.io.IOException, java.sql.SQLException
dbFilename
- full file path of the db fileprovider
- Key provider object storing the SQLCipher key
Supply a NullKeyProvider to use a non-encrypted database.SQLDatabase
for the given filenamejava.io.IOException
- if the file does not exists, and also
can not be createdjava.sql.SQLException
- If the database could not be opened.public static void updateSchema(SQLDatabase database, Migration migration, int version) throws java.sql.SQLException
Update schema for SQLDatabase
Each input schema has a version, if the database's version is
smaller than version
, the schema statements are executed.
SQLDatabase's version is defined stored in user_version
in the
database:
PRAGMA user_version;
This method updates user_version
if the migration is successful.
database
- database to perform migration in.migration
- migration to perform.version
- the version this migration migrates to.java.sql.SQLException
- if migration failsSQLDatabase.getVersion()