realm-java: get Realm file decryption failed
when i’m trying to use encrypt feature on my project, i get this error:
this is my Application class content:
/* SetUp Application database as encrypted contents */
byte[] key = new byte[64];
new SecureRandom().nextBytes(key);
Realm.init(this);
RealmConfiguration realmConfiguration = new RealmConfiguration.Builder()
.encryptionKey(key)
.name("Application.db")
.deleteRealmIfMigrationNeeded()
.build();
full stack error:
Caused by: io.realm.exceptions.RealmFileException: Unable to open a realm at path '/data/data/com.pishguy.androidapplication.cafemaku/files/Application.db': Realm file decryption failed. in /Users/emanuelez/repos/realm/realm-java-private/realm/realm-library/src/main/cpp/io_realm_internal_SharedRealm.cpp line 81 Kind: ACCESS_ERROR.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 16 (8 by maintainers)
… I’ve heard something about a “KeyStore” that you’re supposed to store things in on Android, but I don’t know much about it nor its reliability
You cannot delete a Realm while it is open and
Realm.getDefaultInstance
will open a Realm.Do this instead:
@Zhuinden @brayanL we have a PR about storing key https://github.com/realm/realm-java/pull/4181 , but never get enough time to finish it…
The Realm documentation for Encryption is not very clear: https://realm.io/docs/java/latest/. The code to the example in GitHub is incomplete. They should change it.