Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
agrosner committed Feb 17, 2021
2 parents 76c981f + 1f2f77e commit 86a1fa8
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions usage2/advanced-usage/sqlciphersupport.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,13 @@ You also need to add the Proguard rule:
-dontwarn net.sqlcipher.**
```

Next, you need to subclass the provided `SQLCipherOpenHelper` \(taken from test files\):

```kotlin
class SQLCipherOpenHelperImpl(context: Context,
databaseDefinition: DBFlowDatabase,
callback: DatabaseCallback?)
: SQLCipherOpenHelper(context, databaseDefinition, callback) {
override val cipherSecret get() = "dbflow-rules"
}
```

_Note:_ that the constructor with `DatabaseDefinition` and `DatabaseHelperListener` is required.

Then in your application class when initializing DBFlow:

```kotlin
FlowManager.init(FlowConfig.Builder(context)
.database(
DatabaseConfig.Builder(CipherDatabase::class) { db, callback -> SQLCipherHelperImpl(context, databaseDefinition, callback))
.build())
.build())
FlowManager.init(context) {
database<CipherDatabase>(
openHelperCreator = SQLCipherOpenHelper.createHelperCreator(DemoApp.context, secret = "dbflow-rules"))
}
```

And that's it. You're all set to start using SQLCipher!
Expand Down

0 comments on commit 86a1fa8

Please sign in to comment.