Hello !
I've a pre-bundeld realm (generated with a home-made Node script) that I want to open in my android app using react-native.
Being able to access the data stored in the bundle from react-native. (It's working fine when opening the Realm with Node.)
Red screen error : Unable to open a realm at path ./realm/default.realm.management. Please use a path where your app has read-write permissions.
But it exists, I even created the "default.realm.management" dir, and put chmod 777 to all of this...
File architecture :
.
โโโ ScreenCallingRealm.js
โโโ realm
โย ย โโโ default.realm
โย ย โโโ default.realm.lock
โย ย โโโ default.realm.management
Maybe the Realm path is not relative to the script calling it ? (but would be strange)
Realm.open({
path: './realm/default.realm',
schema: [some, schemas],
}).then((realm) => {
alert(JSON.stringify(realm.objects('Dog').length));
});
}
First, you should only include default.realm. Both .lock and .management are aux. files/directories.
You can use Realm.copyBundledRealmFiles(). I just realized that we forgot to document it :smile:. You can see an example in our tests of it: https://github.com/realm/realm-js/blob/master/tests/js/realm-tests.js#L883
Thanks ! :)
I'll tro to use this feature in a few days then.
@nathan-K- I close the issue for now but don't hesitate to reopen if you experience any issues.
Awesome, it's working !
If it can help, for android :
android/app/src/main/assets
Realm.copyBundledRealmFiles();
Realm.open({
schema: realmConfig.realmSchemas,
path: 'the name of your realm file',
}).then((realm) => {
// do stuff
});
Most helpful comment
Awesome, it's working !
If it can help, for android :
android/app/src/main/assetsRealm.copyBundledRealmFiles(); Realm.open({ schema: realmConfig.realmSchemas, path: 'the name of your realm file', }).then((realm) => { // do stuff });