Hi, I hope this is the right place to ask this question, as I've
nowhere to turn and the db4o forums are desolate, especially when it
comes to Android support.

I am having a problem opening or creating a db4o database, as I
receive a NullPointerException from the Activity I try to access the
database.

Here is part of my DbHelper class:

                private Context context;
                private static ObjectContainer oc = null;

            public DbHelper(Context ctx) {
                context = ctx;
            }
                private ObjectContainer db() {
                try {
                        if(oc == null || oc.ext().isClosed())
                                oc = Db4o.openFile(dbConfig(), 
db4oDBFullPath(context));
                        return oc;
                } catch (Db4oException e) {
                        Log.e(DbHelper.class.getName(), e.toString());
                        return null;
                }
                }

            private Configuration dbConfig(){
                Configuration c = Db4o.newConfiguration();
        
c.objectClass(Materia.class).objectField("codigo").indexed(true);
                return c;
            }

                private String db4oDBFullPath(Context ctx) {
                String dir = ctx.getFilesDir().getParent() + "/databases/";
                File datafile = new File(dir, "sas.db4o");
                return datafile.getAbsolutePath();
            }

                public void addMateria(String codigo, String nombre) {
                db().store(new Materia(codigo, nombre));
                db().commit();
            }

Then, to actually store a Materia object from my Activity class I do:
                DbHelper db = new DbHelper(this);
        db.addMateria("ISC304", "Programacion II");

And this is where I recieve the NullPointerException (in
db().store(new Materia(codigo, nombre)); ). Upon debugging, I noticed
that db() actually returns null, and a Db4oIOException is launched on
that line, which in turn launches the NullPointerException in the VM.
Here is the actual error logged:

ERROR/com.android.sas.db.DbHelper(1129):
com.db4o.ext.Db4oIOException: /data/data/com.android.sas/databases/
sas.db4o

At first I thought it was a problem with the pathname, but I have
confirmed from the docs that /data/data/<package>/databases should
house all databases the application uses, so I'm pretty sure that's
not it.

As the db4o for Android support is pretty scarce on the db4o side, I'd
be thankful if someone here could help me to figure out what's causing
this problem. Let me know if you need anymore information.

Thanks in advance!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to