Upgrading to SQLCipher 4

I tried this on android but its not working on app upgrade, on app upgrade it’s giving “file not database” error message, any idea why I am getting this?

init {
        val hook = object : SQLiteDatabaseHook {
            override fun preKey(database: SQLiteDatabase?) {

            }

            override fun postKey(database: SQLiteDatabase?) {
                database?.rawExecSQL("PRAGMA cipher_migrate")
            }
        }
        sqliteOpenHelper = object : SQLiteOpenHelper(context, name, null, version, hook) {
            override fun onCreate(db: SQLiteDatabase) {
                this@SqliteHelperWrapper.onCreate(getDbWrapper(db))
            }

            override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
                this@SqliteHelperWrapper.onUpgrade(getDbWrapper(db), oldVersion, newVersion)
            }
        }
    }