question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Using Realm with external storage

See original GitHub issue

Goals

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.

screenshot_1524455457

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:closed
  • Created 5 years ago
  • Comments:18 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
cmelchiorcommented, Feb 1, 2019

Fixed in #2235 A release will be made later today

2reactions
cmelchiorcommented, Dec 18, 2018

A few observations:

  • Removing Realm completely and just writing something random to the Download folder works fine. Hinting at Realm trying to write something where it shouldn’t.
  • I tried to create a pure Java app with the same behavior of requesting permissions and then creating a Realm in the 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.
Read more comments on GitHub >

github_iconTop Results From Across the Web

I can't backup my realm database in External Directory ...
You are trying to create the directory "Download" in the root directory ("/"). You need to use Environment.
Read more >
Minecraft Out of storage Bedrock Realm Help. - Mojang
When I try to donwload my realm world, I get a message that says, "You are almost out of data storage space! Minecraft...
Read more >
Minecraft Help Center - Minecraft.net
Minecraft Realms Plus: How do I Join Someone's Minecraft Realm? ... Realms Troubleshooting and Billing ... Mojang Bug Tracker Guidelines and FAQ.
Read more >
Keycloak 19.0.0 released
The Keycloak storage is changing, and the current storage, ... keycloak for the master realm or any other realm, it will continue to...
Read more >
Realmd discovery and join problem - Red Hat Customer Portal
I was initially affected by the bug in Samba 4.9.1 so was unable to use net ads to perform the join, and couldn't...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found