Where can I find the default Realm database file

I started working on the logic of my migration using this code: https://github.com/realm/realm-java/blob/master/examples/migrationExample/src/main/java/io/realm/examples/realmmigrationexample/MigrationExampleActivity. java

And after writing the code, I get an error message on this line:

String path3 = MigrationClass.copyBundledRealmFile(this, this.getResources().openRawResource(R.raw.default1), "default1");

It cannot find the R.raw.default1 file, since so far I have used Realm as a rule:

Realm realm = Realm.getInstance(context);

My question is, where can I get the file path for this realm file?

+4
source share
2 answers

Realm getFilesDir(), Realm default.realm. :

String realmPath = new File(context.getFilesDir(), "default.realm").getAbsolutePath();
Realm.migrateRealmAtPath(realmPath, new CustomMigration());
+7

realm, getPath():

:

realm.getPath()
+6

Source: https://habr.com/ru/post/1584285/


All Articles