Android – how to bundle the realm database file with my application for installation

I have a dataset of about 50K records and I want to put it in the real database. I'm not sure how to create this database in real and bundle it with the application so that the files can reside from the beginning (installation) of the device

resolvent:

You can put the realm file in the assets folder and copy it the first time you open the application. Here is an example of how to do this: https://github.com/realm/realm-java/blob/master/examples/migrationExample/src/main/java/io/realm/examples/realmmigrationexample/MigrationExampleActivity.java#L57

You can then use SharedPreferences / another realm or similar to save Boolean values to indicate that the realm file has been copied

Now we don't have any API to work outside Android, but one way to create a pre populated database is to create a small application, run the application on the simulator, and then use ADB to extract the database: how to view my real file in the real browser?

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>