I have a data set of around 50k records which I want to put in a Realm database. I am unsure of how can I make this DB in Realm and bundle it with the App so that the file can reside from the very start (installation) in the device.
Asked
Active
Viewed 1,307 times
1 Answers
3
You can put a Realm file in your assets folder and copy it the first time you open the app. There is an example on how to do that here: https://github.com/realm/realm-java/blob/master/examples/migrationExample/src/main/java/io/realm/examples/realmmigrationexample/MigrationExampleActivity.java#L57
You can then use SharedPreferencs/another Realm or similar to save a boolean to indicate that the Realm file has been copied.
Right now we don't have any API working outside Android, but one way to create a prepopulated Database is to make a small app that does it, run that that app on an emulator and then use ADB to pull the database: How to view my Realm file in the Realm Browser?

Community
- 1
- 1

Christian Melchior
- 19,978
- 5
- 62
- 53
-
Thank you. I'll give it a try. – jait Mar 12 '16 at 01:21