Posts

Showing posts from December, 2013

Using db4o in Android

Image
db4o is a Object oriented database. This tutorial was written to get you started with db4o as quickly as possible. Before you start, please make sure that you have downloaded the latest db4o distribution from the db4objects website.
In this tutorial I have used db4o-8.0.184.15484-all-java5.jar from dropbox.com

Then kindly put the file in your project's lib folder and configure project's Build Path.

Enough, Let us start !!!

1. Create a class to configure db4o. I named it as Db4oHelper.

Code:

Db4oHelper.java

import java.io.IOException; import android.content.Context; import android.util.Log; import com.db4o.Db4oEmbedded; import com.db4o.ObjectContainer; import com.db4o.config.EmbeddedConfiguration; public class Db4oHelper { private static ObjectContainer oc = null; private Context context; /** * @param ctx */ public Db4oHelper(Context ctx) { context = ctx; } /** * Create, open and close the database */ public ObjectContainer db() { try { if (oc…