Docs Menu
Docs Home
/ /
Atlas Device SDKs
/

Open a Realm File

On this page

  • Overview
  • Open a Local Realm File
  • Find a Realm File
  • Create from a CSV
  • Browse to the Create Realm from CSV option
  • Open your CSV
  • Choose where to store the imported data
  • Add more data to the realm
  • Download an Example
  • Error Opening Realm File

If you have a local realm file that you've created by running a client application, you can open it in Realm Studio.

If you don't already have a realm file, you can create one by importing a CSV, or you can download a demo file.

You can use Realm Studio to open and explore a local realm file. This could be a file generated from running an emulator on your local machine, or a file from another source. Some development tools even allow you to view and edit the realm file while the emulator is running. This workflow supports fast, simple iteration for changes to objects and schemas.

Realm stores a binary-encoded version of every object and type in a single realm file. The file is located at a specific path that you define when you open the realm.

To find your default realm file path:

// Get on-disk location of the default Realm
let realm = try! Realm()
print("Realm is located at:", realm.configuration.fileURL!)
// Open a realm.
const realm = await Realm.open({
schema: [Car],
});
// Get on-disk location of the Realm
const realmFileLocation = realm.path;
console.log(`Realm file is located at: ${realm.path}`);

The filesystem used by Android emulators is not directly accessible from the machine running Realm Studio. You must download the file from the emulator before you can access it.

First, find the path of the file on the emulator:

// Run this on the device to find the path on the emulator
Realm realm = Realm.getDefaultInstance();
Log.i("Realm", realm.getPath());

Then, download the file using ADB. You can do this while the app is running.

> adb pull <path>

You can also upload the modified file again using ADB, but only when the app isn't running. Uploading a modified file while the app is running can corrupt the file.

> adb push <file> <path>
var realm = Realm.GetInstance();
Console.WriteLine($"Realm is located at: {realm.Config.DatabasePath}");
// Get on-disk location of the default Realm
final storagePath = Configuration.defaultStoragePath;
// See value in your application
print(storagePath);
config = SyncConfiguration.Builder(user, setOf(Item::class))
.initialSubscriptions { realm ->
add(
realm.query<Item>(
"owner_id == $0",
realmApp.currentUser!!.identity
),
"User's Items"
)
}
.build()
// Log on-disk location of the realm file
Log.v("My Tag", "Realm Path: ${config.path}")

Once you know the location of your local realm file, you can browse to that location from the Open Realm file dialog.

Note

Files at hidden paths

On MacOS, the default location for Xcode emulator files is under the ~/Library folder. By default, this is a hidden directory. You may not be able to browse to this location from the Open Realm file dialog.

Use another technique to view the file, such as Go to Folder in Finder, and open the realm from there.

If you don't have a local realm file, you can create one from a CSV in Realm Studio.

When you create a realm from CSV, Realm Studio infers these details:

  • The name of your CSV becomes the class name in the realm file

  • The first row of your CSV becomes the class property names in the realm

  • The values of each column shape the class property types. A column of 'true' and 'false' values becomes a boolean property type. A column of whole numbers becomes an integer property type, and so on. If Realm Studio can't determine the property type, it becomes a string.

For example, a CSV named data.csv with this formatting:

1device,number,flag
2gizmo,1,TRUE
3widget,2,FALSE

Becomes a class model named data that has three properties:

  • device, with a type string

  • number, with a type int

  • flag, with a type bool

1

In Realm Studio, go to: File > Create Realm from > CSV

2

Browse to the location of your CSV file, and select it.

Press the Open button.

3

Enter a name for the realm file that will be created from your CSV.

Browse to the location where you want to save it.

Press the Save button.

4

When you create a new realm file from a CSV, you may get this message:

"Failed to import data: Class name (name-of-file.csv) missing from schema"

If this happens, press OK. You'll see that creating a realm from your CSV has created a class definition, but there are no objects in your realm. From here, you can Import from a CSV to populate your realm with object that map to the class definition you just created.

If you're new to Realm and don't have a realm file or CSV to import, you can still try out Realm Studio.

When you open Realm Studio, you'll see an option to Download a demo Realm file.

When you click the link to download the demo file in Realm Studio, you can specify a name and location to save a realm file containing demo data. Once you have downloaded the file, you can use the Open Realm file dialog to open it.

If you get an error when you try to open a realm file, this may be due to a version mismatch between the Realm file format supported in Realm Studio and the Realm file format produced by the SDK.

To verify compatibility, check the release notes for your SDK version or your Realm Studio version. You may need to upgrade or downgrade Realm Studio or the Realm SDK version.

These error messages may resemble:

Realm file is currently open in another process which cannot share access
with this process. All processes sharing a single file must be the same
architecture.
The file is already opened by another process, with an incompatible
lock file format. Try up- or downgrading Realm Studio or SDK to match
their versions of Realm Core.

Back

View Data with Device Sync