Skip to content

How to migrate from SafeHelperFactory to SupportOpenHelperFactory while keeping existing encrypted database accessible #66

@viethoangtien

Description

@viethoangtien

I’m migrating from SQLCipher’s legacy SafeHelperFactory to SupportOpenHelperFactory in the new net.zetetic:sqlcipher-android library

Previously, I used:

val phrase: CharArray = password.toCharArray()
factory = SafeHelperFactory(phrase, SafeHelperFactory.POST_KEY_SQL_MIGRATE)

Now I changed it to:

val phrase: ByteArray = password.toByteArray(Charsets.UTF_8)
factory = SupportOpenHelperFactory(phrase)

But I can no longer open the database encrypted with the previous SafeHelperFactory. It throws a net.sqlcipher.database.SQLiteException: file is not a database.

  • The password is the same

  • The database file is preserved

  • Migration fails silently or throws an error

What is the correct way to migrate an existing SQLCipher-encrypted Room database from SafeHelperFactory to SupportOpenHelperFactory while preserving the data.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions