Hi,

Use a content provide as a wrapper over your sqlite database, then you
can safely access from activity and service even if these are in
different processes, the content provider seems to perform the
expected serialization of requests.

http://developer.android.com/guide/topics/providers/content-providers.html

Works for me.

Regards



On Feb 25, 10:06 am, DanH <danhi...@ieee.org> wrote:
> As I understand it, SQLite on Android is not compiled to enable
> locking.  Not that it matters that much -- when "locking" is done all
> that really happens is that the second thread/process gets a SQL error
> if the first thread/process has the DB busy -- there's no "wait"
> performed.  The lock feature prevents corruption of the DB, but does
> not allow it to smoothly handle multiple simultaneous accesses.
>
> So even if SQLite locking is enabled, you still need a semaphore or
> some such to keep multiple threads/processes from conflicting over the
> DB.
>
> On Feb 24, 11:43 am, Greg Donald <gdon...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Is it possible for an activity and a service to both have simultaneous
> > access to the same sqlite db?  So far I can't seem to find a way due
> > to the "failed to close()" exception I get when I make the second
> > connection.  I've tried a couple different setups so far, and it seems
> > my only option may be to have my db stuff live inside the service so I
> > never need the second connection.  Is my thinking correct or am I
> > missing something?
>
> > Thanks,
>
> > --
> > Greg Donald
> > destiney.com | gregdonald.com

-- 
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