[BUG] Using Realm with external storage
See original GitHub issueGoals
I want to use sdcard on Android to save and load Realm data.
Expected Results
The file can be created and loaded without problems using app’s folder on external storage.
Actual Results
Unfortunately, when running Realm.open, it throws an exception of “Read-only file system”, even after giving runtime permission to read and write external storage. I can see the file was created at the specified path.
Steps to Reproduce
It’s an old issue that still not fixed. Please also see: #1760 Use below code sample
Code Sample
I open my database like this in react-native:
componentWillMount() {
Realm.open({
schema: [ Constant.BookSchema ],
path: '/storage/sdcard0/BookDB/db.realm'
}).then(realm => {
// some code here
});
}
I also add this two line to my AndroidManifest.xml
:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
It’s create below files in this location /storage/sdcard0/BookDB
:
db.realm.managment
access_control.control.mx
access_control.write.mx
db.realm
db.realm.lock
But It’s return red error page with Read-only file system
error. (something like above image)
My device just have internal storage with /storage/sdcard0
location and it’s not have any external SD card. (with Android 5.1.1 OS)
Version of Realm and Tooling
* Realm JS SDK Version: 2.15.3
* Node or React Native: 0.55.4
* Client OS & Version: Android API 25, 27
* Which debugger for React Native: None
Issue Analytics
- State:
- Created 5 years ago
- Comments:18 (6 by maintainers)
Top GitHub Comments
Fixed in #2235 A release will be made later today
A few observations:
Download
folder works fine. Hinting at Realm trying to write something where it shouldn’t.Download
folder. This works fine, which indicates a problem more directly with RealmJS or ReactNative, but since Java and JS instantiate things slightly differently, I’m still investigating that.