Tuesday, October 11, 2011

[android-developers] Re: SQLite concurrency

It's probably needed to clean up stuff, but not closing the database
doesn't seem to cause data corruption, and that all it matters when it
comes to the system just terminating the app.

On Oct 11, 10:52 pm, Christopher Van Kirk
<christopher.vank...@gmail.com> wrote:
> It would be odd to add a close method to a system that wasn't needed for
> some reason.
>
> On 10/11/2011 8:28 PM, Zsolt Vasvari wrote:
>
>
>
> > No, I am not worried about the database not closed.  I don't think it
> > can lead to data corruption.
>
> > On Oct 11, 6:55 pm, Mark Murphy<mmur...@commonsware.com>  wrote:
> >> On Tue, Oct 11, 2011 at 6:13 AM, Zsolt Vasvari<zvasv...@gmail.com>  wrote:
> >>> The only problem is that the datrabase is never closed.  But this is
> >>> more of a pedentic observation as there seems to be no real side
> >>> effects.
> >> Yeah, content providers suffer from the same issue. I fought and
> >> fought against singleton databases and content providers, trying to
> >> find a way to close the database, and eventually surrendered.
>
> >> If you're really paranoid about it, you might rig up some sort of
> >> inactivity timer that closes the database, and organize your singleton
> >> to lazy-open the database if needed. This isn't a guarantee that it'll
> >> get closed, though, as Android could terminate the process first.
>
> >> Having multiple SQLiteDatabase objects is fine if (and only if) you're
> >> only using them from one thread at a time via your own
> >> synchronization. Or if you're accessing the databases on the main
> >> application thread, like some balding guy I know has in one of his
> >> books that's scheduled for an overhaul in 2012... :-)
>
> >>> I do wish there were a onDestory() on the Application object
> >>> so I could close the databases before Android terminates my app, but
> >>> alas, there isn't.
> >> Well, there is onTerminate(), but it's never used.
>
> >> --
> >> Mark Murphy (a Commons Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> >> Android Training...At Your Office:http://commonsware.com/training- Hide quoted text -
>
> - Show quoted text -

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

No comments:

Post a Comment