javakotlinandroid-roomdatabase-migrationsqlite-cipher

Migration from SQLCipher V1 to Room DB V2 on App Update:


I build two apps with the same package name:

  1. In the first app, I use SQLCipher using "Pass_Phrase" (Version_1 DB) for CRUD operations using Java.
  2. In the second app, I just wanted to migrate from SQLCipher to Room (Version_2 DB) and also read data from SQLCipher and put it into Room DB using Kotlin.

I completed the first app and was stuck at migration's step in the second app. Need your help. Thanks a lot!


Solution

  • For 2. you could use a Migration, this has the Room database passed to it as a SupportSQLiteDatabase

    So you could then either

    When a database is attached, then it's components, such as tables, are available (you should use the given schema_name to distinguish components with the same name). See ATTACH

    The answer here includes an example that uses the first method (as per the MainDatabase class, albeit in Java (which should take little effort to convert to Kotlin))