0

I have a realm database file available in the android asset folder. So how to manipulate data from the available realm database file.

2 Answers2

0

You should copy your realm file from assets to file directory, because you can only read files from assets, not write them : https://stackoverflow.com/a/3845559/1243048

To open an asset file : read file from assets

Copy file from assets : android:- how to copy image from Assets to SD Card?

To set realm file path when creating configuration : https://realm.io/docs/java/latest/#configuring-a-realm

Maelig
  • 2,046
  • 4
  • 24
  • 49
-1

Try this in background thread:

Realm realm = Realm.getDefaultInstance();
MyData data = new MyData(); // extends RealmObject
realm.insertOrUpdate(data);
realm.close();

Enclose it in try-catch-finally.

fiveelements
  • 3,649
  • 1
  • 17
  • 16