On Thu, Apr 7, 2011 at 12:18 PM, Emanuel Moecklin <1gravity...@gmail.com>wrote:

> Using a singleton to open the database, where/when would you close the
> database?
> Should the singleton keep track of open connections from clients (the
> singleton would expose a close method) and close it when all
> "connections" are closed or should Application be sub-classed and the
> db closed in onDestroy()?
>

Don't worry about closing it.  Why do you want to close it?  You might as
well keep it open so the next time you need it you'll have it right there.

You can try to open and close the database as you need it (for example in
each activity onCreate() and onDestroy()), but that is a huge amount of
work, and for what?  Mostly it will just close down your app as you keep on
opening the db when you need it again.

-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

-- 
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
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to