简体   繁体   中英

How to get db4o file already created and use it into Android app?

I've created a database named test.db4o with some data. I need to use that database, already with some data into an android application. I'm copying the database's file to sdcard but when i try to retrieve the data it returns nothing... like a brand new database... if i copy the database to another java application it works fine... but when i copy it into android it doesn't work...

Someone know how to make it works?

Do I understand this right? You want to include a prepared database with your application?

Well what I would try is this. You include the prepared database in your APK. See this this Stackoverflow question .

Then you copy that resource in case the database file doesn't exist yet. Basically read from the resource raw stream and copy everything to the new file. Then finally you can open the prepared database with db4o.

Another, probably simpler way is to just include code which fills the database with the required things.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM