File tree Expand file tree Collapse file tree 2 files changed +22
-20
lines changed
android-database-sqlcipher/src/main/java/net/sqlcipher/database Expand file tree Collapse file tree 2 files changed +22
-20
lines changed Original file line number Diff line number Diff line change 2020
2121public class SupportFactory implements SupportSQLiteOpenHelper .Factory {
2222 private final byte [] passphrase ;
23- private final String postKeySql ;
23+ private final SQLiteDatabaseHook hook ;
2424
2525 public SupportFactory (byte [] passphrase ) {
26- this (passphrase , null );
26+ this (passphrase , ( SQLiteDatabaseHook ) null );
2727 }
2828
29- public SupportFactory (byte [] passphrase , String postKeySql ) {
29+ public SupportFactory (byte [] passphrase , final String postKeySql ) {
30+ this (passphrase , new SQLiteDatabaseHook () {
31+ @ Override
32+ public void preKey (SQLiteDatabase database ) {
33+ // unused
34+ }
35+
36+ @ Override
37+ public void postKey (SQLiteDatabase database ) {
38+ if (postKeySql != null ) {
39+ database .rawExecSQL (postKeySql );
40+ }
41+ }
42+ });
43+ }
44+
45+ public SupportFactory (byte [] passphrase , SQLiteDatabaseHook hook ) {
3046 this .passphrase = passphrase ;
31- this .postKeySql = postKeySql ;
47+ this .hook = hook ;
3248 }
3349
3450 @ Override
3551 public SupportSQLiteOpenHelper create (SupportSQLiteOpenHelper .Configuration configuration ) {
36- return new SupportHelper (configuration , passphrase , postKeySql );
52+ return new SupportHelper (configuration , passphrase , hook );
3753 }
3854}
Original file line number Diff line number Diff line change @@ -24,24 +24,10 @@ public class SupportHelper implements SupportSQLiteOpenHelper {
2424 private byte [] passphrase ;
2525
2626 SupportHelper (final SupportSQLiteOpenHelper .Configuration configuration ,
27- byte [] passphrase , final String postKeySql ) {
27+ byte [] passphrase , final SQLiteDatabaseHook hook ) {
2828 SQLiteDatabase .loadLibs (configuration .context );
2929 this .passphrase = passphrase ;
3030
31- SQLiteDatabaseHook hook = new SQLiteDatabaseHook () {
32- @ Override
33- public void preKey (SQLiteDatabase database ) {
34- // unused
35- }
36-
37- @ Override
38- public void postKey (SQLiteDatabase database ) {
39- if (postKeySql != null ) {
40- database .rawExecSQL (postKeySql );
41- }
42- }
43- };
44-
4531 standardHelper =
4632 new SQLiteOpenHelper (configuration .context , configuration .name ,
4733 null , configuration .callback .version , hook ) {
You can’t perform that action at this time.
0 commit comments