0

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?

Igor
  • 1,397
  • 3
  • 24
  • 56

1 Answers1

0

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.

Community
  • 1
  • 1
Gamlor
  • 12,978
  • 7
  • 43
  • 70
  • Well, i've copied the full file with populated database... but when i ask to read the data is returns zero registers... like no one is already inserted before... then if i insert a new one and then ask to read it, it reads normally... so its working like i've a brand new database... – Igor Mar 20 '12 at 00:53
  • What if you just read the file with regular IO operations. Do you then get any content? – Gamlor Mar 20 '12 at 13:38
  • Hmm, so the issue is definatly withing db4o. Do you can a small example app to demostrate the issue? Then I would take a look. – Gamlor Mar 20 '12 at 17:58