Usage of the db40 object-oriented database operation tool class
Package COM. example. test; import Java. io. file; import android. content. context; import android. OS. environment; import COM. db4o. db4oembedded; import COM. db4o. objectcontainer; public class db4outils {// location of the db4o database file public static final string db_path = "/sunlifeeverbright/Banca/advert. db4o "; public static objectcontainer instance = NULL; private db4outils () {} public static objectcontainer initdb4o () {objectcont Ainer DB = NULL; If (environment. getexternalstoragestate (). equals (environment. media_mounted) {try {string dbpath = environment. getexternalstoragedirectory (). tostring () + db_path; file = new file (dbpath); If (! File. exists () file. createnewfile (); DB = db4oembedded. openfile (db4oembedded. newconfiguration (), dbpath);} catch (exception e) {e. printstacktrace () ;}} return dB;}/*** get the objectcontainer object Singleton to implement * @ return */Public synchronized static objectcontainer getinstance () {If (instance = NULL) {instance = initdb4o ();} return instance;}/*** close dB link */public static void close () {If (instance! = NULL) {instance. Close ();}}}