Tools for db4o

Source: Internet
Author: User
 
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 ();}}}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.