# Custom error handler when using sqlcipher with sqldelight (Android)

**URL:** <https://discuss.zetetic.net/t/custom-error-handler-when-using-sqlcipher-with-sqldelight-android/5336>\
**Category:** Issues\
**Created:** [March 23, 2022, 6:32am UTC](https://discuss.zetetic.net/t/custom-error-handler-when-using-sqlcipher-with-sqldelight-android/5336 "2022-03-23T06:32:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcardar](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/marcardar/32/1524_2.png) [@marcardar](https://discuss.zetetic.net/u/marcardar)\
**Post date:** [March 23, 2022, 6:32am UTC](https://discuss.zetetic.net/t/custom-error-handler-when-using-sqlcipher-with-sqldelight-android/5336/1 "2022-03-23T06:32:00Z")

</div>

I’d like to change the default behavior when the database becomes corrupt. This is because, if the corruption is in FTS5 tables, then often those can just be recovered with an FTS5 rebuild, thus preserving the rest of the database.

However, I’m struggling to find a way to override the default error handler when using sqldelight. I’ve tried overriding the callback when setting up the driver, but that didn’t seem to do anything.

```auto
AndroidSqliteDriver(
    schema,
    context,
    name = dbFilenameOrPath,
    factory = openHelperFactory,
    callback = object : AndroidSqliteDriver.Callback(schema) {
    	....

        override fun onCorruption(db: SupportSQLiteDatabase) {
            // super.onCorruption(db)
            println("when there is a corruption, this is never printed. Instead the database is deleted as per the default behavior")
        }
    },
)

```

Is there another way?

---

<div class="post-metadata">

**Author:** ![Yosra](https://avatars.discourse-cdn.com/v4/letter/y/41988e/32.png) [@Yosra](https://discuss.zetetic.net/u/Yosra)\
**Post date:** [April 25, 2023, 10:56am UTC](https://discuss.zetetic.net/t/custom-error-handler-when-using-sqlcipher-with-sqldelight-android/5336/2 "2023-04-25T10:56:52Z")

</div>

Please ,may you share with me an sample project that shows the implementation of SQLCipher encryption to SQLDelight database in Kotlin android
