Can I ship an android app, with a pre-populated objectbox db in it

血红的双手。 提交于 2020-06-13 05:56:28

问题


Pretty much as the title says.

I want to launch my Android app, using ObjectBox, but I'd like the data to be prepopulated in the boxes.

Can I package both data.mdb and lock.mdb inside the app, from data I've created during development?

Or is there device specific stuff in there that will need to be generated on each specific device individually.

EDIT -

On checking how big my data.mdb file is it's HUGE!!! I am trying to store a dictionary of words. It has 370k 'rows' each containing a single word, and linking to another box which has a single value in. The file is 171Mb big!! That's outrageous!!!

I have it indexed, and have read that indexes make things large. Is this the case? Is there anything I can do about it?


回答1:


As to the original question: yes, you can ship your app with an initial data file. You can prepare an ObjectBox database with all the data you need and then grab the data.mdb from the db director (default name is "objectbox").

The BoxStoreBuilder offers the overloaded method initialDbFilethis:

initialDbFile(java.io.File initialDbFile)

initialDbFile(Factory<java.io.InputStream> initialDbFileFactory)

Thus, you can either provide a File or an InputStream.



来源:https://stackoverflow.com/questions/51735068/can-i-ship-an-android-app-with-a-pre-populated-objectbox-db-in-it

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!