Thanks for the good advice. To make the database accessible in other Activities I initialize again in each Activity, which seems to work, but I get log messages that say I need to close the database. If I close the database when leaving an activity, then it isn't available in onActivityResult when it returns, so I have to initialize again. It seems like I am initializing and closing way too much and it is obvious I don't know what I am doing! When you stay the database stays around forever until the process is killed, is there a simpler way to do multiple activities? Do I need to close the database when the process is killed or does Android do it?
On Feb 27, 1:27 am, Dianne Hackborn <[email protected]> wrote: > I would recommend having a static singleton objects that is used to access > the database -- it creates the database when it is first retrieved as part > of its initialization, allows clients to get the database and/or provides > convenience APIs for interacting with the database, and simply stays around > forever (until the process is killed). > > > > > > On Fri, Feb 26, 2010 at 10:07 PM, Paul <[email protected]> wrote: > > What is the best approach to managing a small SQLite database private > > to the application? > > Open (getWritableDatabase) in OnStart and close in OnStop in each > > Activity? > > Open in OnCreate and keep open til the user quits the app (where would > > you put close?) > > Open, do work and close as soon as possible each time it is needed? > > > -- > > You received this message because you are subscribed to the Google > > Groups "Android Developers" group. > > To post to this group, send email to [email protected] > > To unsubscribe from this group, send email to > > [email protected]<android-developers%2Bunsubs > > [email protected]> > > For more options, visit this group at > >http://groups.google.com/group/android-developers?hl=en > > -- > Dianne Hackborn > Android framework engineer > [email protected] > > 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

