Skip to content

Realm not copying database from assets #2933

@AlexLardschneider

Description

@AlexLardschneider

Goal

What do you want to achieve?
Copy a pre-filled database from assets by using .assetFile(context, "default.realm")

Expected Results

Database gets copied and contains all the data

Actual Results

Copied database is only 4kb in size, while the original database in the assets folder is 123kb in size.
Using realm.isEmpty() returns true, which it should not. The Realm Browser for OS X correctly shows all the data in the database. Using realm.where() always returns an empty result.

Steps & Code to Reproduce

RealmConfiguration config = new RealmConfiguration.Builder(context)
.name("default.realm")
.schemaVersion(1)
.assetFile(context, "default.realm")
.deleteRealmIfMigrationNeeded()
.build();

Realm realm = Realm.getInstance(config);
realm.isEmpty() // => true

Using this code, realm.isEmpty() always prints true

Version of Realm and tooling

Realm version(s): 1.0.0

Android Studio version: 2.2 Preview 2

Which Android version and device: CM 13 Android 6.0.1 Galaxy S5 klte

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions