Notwithstanding the original poster's questions, it seems like, in general, opening and closing the connection each time you use the database is unnecessary overhead, unless you know that your app is only going to access the database at very discrete times. If your application uses the database much, shouldn't you just open it in onStart and close in onDestroy?
Gary On Apr 8, 6:24 pm, NoImJosh <[email protected]> wrote: > From my experience, when you do not call dbHelper.close(), the system > does take care of it for you, but raises an exception in the > debugger. While this exception is not a Force Close, I do believe the > best practice would be to have your widget (in it's update script) run > dbHelper.open() and when it is finished running dbHelper.close(). I > try to make it a point to only run dbHelper.open() right before I > access the database within a function, then I promptly call > dbHelper.close() when finished with it (in the same function). > > On Apr 8, 4:55 am, "Teo [GD API Guru]" <[email protected]> wrote: > > > I have a DatabaseHelper instance for db stuff. Until now i kind of had > > a mess of everything but made it a singleton so it won't need to be > > created over and over again. The same object is used both in the > > fullscreen app and in the widget. The thing is, in case the user also > > has my widget on the home screen, when the fullscreen app is closed i > > wouldn't want to close the dbHelper in onDestroy. My question is: does > > Android or the garbage collector do all the necessary stuff to release > > the memory in case it *isn't* used again? (the case in which the > > widget isn't added) > > > Thanks, > > Teo -- 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 To unsubscribe, reply using "remove me" as the subject.

