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?
Realm getFilesDir(), Realm default.realm. :
getFilesDir()
default.realm
String realmPath = new File(context.getFilesDir(), "default.realm").getAbsolutePath(); Realm.migrateRealmAtPath(realmPath, new CustomMigration());
realm, getPath():
:
realm.getPath()