Question

I am using db4o in my android application, and I seem to have some trouble in creating a database file. I am using this line of code below:

 ObjectContainer db = Db4oEmbedded.openFile(Db4oEmbedded.newConfiguration(), "Teams");  

Which last I heard it would create a DB for you, and then you could manipulate it from there. Every time I run my app it crashes whenever I try to create the database called "Teams" it doesn't work. I have scoured the internet for a solution and I have not been able to find one.

I got to the root of the problem, it seems to be that

 Db40Embedded.newCOnfiguraiton() ///is what is causing the crash...

So I tried this:

        final EmbeddedConfiguration config = Db4oEmbedded.newConfiguration();// crashes here
        config.common().add(new AndroidSupport());

        db = Db4oEmbedded.openFile(config, dbPath);

But it still crashes on the same line... What could be wrong?

Can anyone show me how to please create a database file, not how to use db4o (CRUD operations). All I need is to know how and where to store and create a database file that works with db4o for my android application.... Thanks!

I think I found what the problem is:

http://mavistechchannel.wordpress.com/2011/11/18/db4o-at-honeycomb-and-ice-cream-sandwich/

Anyone know how to fix it?

I FIGURED IT OUT! LOOK BELOW!

Was it helpful?

Solution 2

I finally figured it out! To use the code above:

  final EmbeddedConfiguration config = Db4oEmbedded.newConfiguration();// crashes here
  config.common().add(new AndroidSupport());

  db = Db4oEmbedded.openFile(config, dbPath);

All you need to do is download the latest 8.1 version of db4o and place it in the 'libs' folder, and you should add it to the Android Private Libraries. Once the jar is there, then you can run all the code you want related to db4o. Below is an example:

Here is a simple example:

OTHER TIPS

Didn't heard about or worked with this before, just trying to help you get out of this. Check this link. And, this may be the link you visited.

Not sure if this would help you or not.

Also, you can search here on their community: http://community.versant.com/Search.aspx?Search=android

Reference links:

https://gist.github.com/zapnap/737753

http://source.db4o.com/db4o/trunk/reference/CodeExamples/javaAppExamples/Android/src/com/db4odoc/android/Db4oExample.java

http://v4all123.blogspot.in/2013/12/using-db4o-in-android.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top