I have a realm database file available in the android asset folder. So how to manipulate data from the available realm database file.
Asked
Active
Viewed 435 times
0
-
1Check this: https://stackoverflow.com/questions/45407852/realm-database-read-data-from-android – fiveelements Jul 22 '19 at 18:40
2 Answers
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