How to find my realm file?

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


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.


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

Tags:

Realm