Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find my realm file?

Tags:

realm

People also ask

How do I open a Realm file?

How to open a REALM file. You can open a REALM file in MongoDB Realm Studio (cross-platform). To do so, open Realm Studio, select the Open Realm file button, and then navigate to and open your REALM file. The data your REALM file contains will appear in Realm Studio.

Where is Realm database stored Android?

You can find your realm file in the Device File Explorer tab at the bottom right of Android Studio. The location will be /data/data/com. <package-name>/files/default. realm assuming you haven't named your realm file.

What is MongoDB Realm studio?

Realm Studio is a visual tool to view, edit, and design Realm Database files. With Realm Studio, developers can: Query objects in the database. View live objects in realtime while running an app. Create, modify, and delete objects.


Finding a Realm File

For Android

How to view my Realm file in the Realm Browser?

For iOS

If your App is on Device

Make sure that your device is connected and go to the devices window in the Xcode menu Window > Devices (⌘⇧2). There you will be able to choose your device and your app from a list of installed apps with debugging permissions.

After selecting your app, go to the cog in the toolbar at the bottom of the table view and select “Download Container…“. There you will be able to pull the file from the documents location to your Mac. It will be saved as an xcappdata bundle.

When you open the local path in Finder, where you saved it, you can tap into that by selecting “Show Package Contents” in the context menu of the finder, when you select the file. A new finder window will open, where you find your Realm inside in the following path (e.g.): AppData/Documents/default.realm (The directory '/private/var/mobile' is the path, which is used by iOS on the device filesystem.

If your App is on the Simulator

Go to your user’s directory:

/Users/<username>/Library/Developer/CoreSimulator/Devices/<simulator-uuid>/data/Containers/Data/Application/<application-uuid>/Documents/default.realm

Probably the easiest way to get the current path of the default realm is to pause the simulator and enter the following into the LLDB console:

Objective-C:
(lldb) po [RLMRealmConfiguration defaultConfiguration].fileURL

Swift using Realm Objective-C:
(lldb) po RLMRealmConfiguration.defaultConfiguration().fileURL

Swift using Realm Swift:
(lldb) po Realm.Configuration.defaultConfiguration.fileURL

Or if you have an RLMRealm instance at hand, you can use:
(lldb) po myRealm.configuration.fileURL

Then just copy this path, open your terminal, and type open [Pasted path here]

NOTE: Some paths have a space in them so be sure to use "\" before the space to escape it

Helper Tool SimPholders

This is probably the fastest way to find the file of an app in the simulator. Install SimPholders. This will allow you to access your app’s documents directory directly from your menu bar.

Note Some people have mentioned that SimPholders has taken them to the wrong simulator app folder, if that's the case for you, print out your realm path by following the steps above, printing out your realm.path


I found most simplest way for iOS/macOS (for swift 3 Xcode 8.3)

override func viewDidLoad() {

   // for swift 2.0 Xcode 7
   print(Realm.Configuration.defaultConfiguration.fileURL!)
}

Then x code will log the correct path, check the screen below.

enter image description here

Now open your Finder and press + + G (command+shift+G) and paste the path that logs on your Xcode


One Easy Alternative For Simulator Apps

Create a smart folder/search in Finder. Gives quick and easy clickable access to all your realm files.

  1. Open the folder /Users/$USER/Library/Developer/CoreSimulator/Devices in Finder.

    With terminal open /Users/$USER/Library/Developer/CoreSimulator/Devices

  2. Search for .realm

  3. Change the search to look in the "Devices" folder only.

  1. Save the search to your sidebar (e.g. as Realms)

When sorted by date this will give you a quick and easy clickable list of the latest modified Simulator .realm files.


Here is an easy solution.. I messed with this for awhile. I should point out, this is a specific set of instructions using Android Studio and the AVD Emulator.

1) Start the Emulator and run your app.

2) While the app is still running, open the Android Device Monitor. (its in the toolbar next to the AVD and SDK manager icons)

3) Click the File Explorer tab in the Device Monitor. There should be a lot of folders.

4) Navigate the following path: Data > Data > Your Package Name > files > Default.Realm (or whatever you named it)

Ex. If you are using one of the realm example projects, the path would be something like Data>Data>io.realm.examples.realmgridview>files>default.realm

5) Highlight the file, click the Floppy Disk icon in the upper right area "pull a file from the device"

6) Save it off to whereever you want and done.


What I did was to use

let realm = Realm(path: "/Users/me/Desktop/TestRealm.realm")

and then it gets created in full view on my desktop and I can double-click to launch the Realm Browser on it. Later, I can remove the parameter and let it use the default location when I'm satisfied that all is working as expected.


The above answers missing a way to find the realm file in Android platform and believe me this way will save your lot's of time which we generally waste in other approaches to get the realm file. So let's start...

First open "Device File Explorer" in android studio(View -> Tools Windows -> Device File Explorer.

This will open your device explorer.

enter image description here

now open data -> data -> (your_app_package_name) -> files -> default.realm

default.realm is the file for which we are here. Now Save_as this file at your location and access the file from the realm_browser and you will get your database.

NOTE: Mentioned approach is tested on non-rooted phone(one+3).


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!