Skip to content

Commit cc47c99

Browse files
Capture database password (byte[]) and SQliteDatabaseHook for configuration
1 parent 23730bb commit cc47c99

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

sqlcipher/src/main/java/net/zetetic/database/sqlcipher/SQLiteDatabaseConfiguration.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,16 @@ public final class SQLiteDatabaseConfiguration {
8787
*/
8888
public boolean foreignKeyConstraintsEnabled;
8989

90+
/**
91+
* The password to use with a SQLCipher database
92+
*/
93+
public byte[] password;
94+
95+
/**
96+
* The database hook to use with a SQLCipher database
97+
*/
98+
public SQLiteDatabaseHook databaseHook;
99+
90100
/**
91101
* The custom functions to register.
92102
*/
@@ -101,14 +111,28 @@ public final class SQLiteDatabaseConfiguration {
101111
* @param openFlags Open flags for the database, such as {@link SQLiteDatabase#OPEN_READWRITE}.
102112
*/
103113
public SQLiteDatabaseConfiguration(String path, int openFlags) {
114+
this(path, openFlags, null, null);
115+
}
116+
117+
/**
118+
* Creates a database configuration with the required parameters for opening a
119+
* database and default values for all other parameters.
120+
*
121+
* @param path The database path.
122+
* @param openFlags Open flags for the database, such as {@link SQLiteDatabase#OPEN_READWRITE}.
123+
* @param password The password to use for a SQLCipher database
124+
*/
125+
public SQLiteDatabaseConfiguration(String path, int openFlags, byte[] password,
126+
SQLiteDatabaseHook databaseHook) {
104127
if (path == null) {
105128
throw new IllegalArgumentException("path must not be null.");
106129
}
107130

108131
this.path = path;
109132
label = stripPathForLogs(path);
110133
this.openFlags = openFlags;
111-
134+
this.password = password;
135+
this.databaseHook = databaseHook;
112136
// Set default values for optional parameters.
113137
maxSqlCacheSize = 25;
114138
locale = Locale.getDefault();
@@ -148,6 +172,8 @@ public void updateParametersFrom(SQLiteDatabaseConfiguration other) {
148172
maxSqlCacheSize = other.maxSqlCacheSize;
149173
locale = other.locale;
150174
foreignKeyConstraintsEnabled = other.foreignKeyConstraintsEnabled;
175+
password = other.password;
176+
databaseHook = other.databaseHook;
151177
customFunctions.clear();
152178
customFunctions.addAll(other.customFunctions);
153179
}

0 commit comments

Comments
 (0)