0

I could find a lot of integration samples for old versions of SQLCipher with android and it also works. But I need to integrate latest version of SQLCipher like v4.5.4 because it mentioned that that it has more performance optimisations. Could anyone help me with this?

I tried with the steps given in the SQLCipher latest documentation but I could not follow that because it is not clear and requires the database file path which I have no idea how to take.

1 Answers1

0

I've got it

        System.loadLibrary("sqlcipher")
        val factory = SupportOpenHelperFactory(encryptionKey)
        // if the INSTANCE is not null, then return it,
        // if it is, then create the database
        return INSTANCE ?: synchronized(this) {
            val instance = Room.databaseBuilder(
                context.applicationContext,
                MYDatabase::class.java,
                DATABASE_NAME
            )
                .openHelperFactory(factory)
                .addMigrations(MIGRATION_1_2, MIGRATION_2_3, MIGRATION_3_4, MIGRATION_4_5)
                .build()
            INSTANCE = instance
            // return instance
            instance
        }

Here System.loadLibrary("sqlcipher") should be called before any database operation has occurred