[android-developers] Re: Concurrent database activity
Java has several synchronization primitives. Simplest would be to
have all accesses synchronized on the same object, or you could use a
Semaphore.
Likely the DB is never tied up for more than a second or so, so
there's not too much danger if you were to access from the main
thread.
On Feb 11, 5:35 pm, Julius Spencer <jul...@msa.co.nz> wrote:
> Hi Dan,
>
> Thanks for the reply. This sounds like something worth trying; would I store a boolean in the Application with synchronized accessors to determine whether a write operation is occurring and then put some kind of wait around write operations in a loop for the case where there is contention to keep trying until it is successful?
>
> I guess I'd just have to be careful where the operations were taking place that they were never on the main UI thread.
>
> Regards,
> Julius.
>
> On 12/02/2011, at 8:58 AM, DanH wrote:
>
> > SQLite implements its own locking protocol internally. If you want
> > operations to wait rather than fail, you need to wrap operations from
> > both sources with your own synchronization primitives that wait rather
> > than fail.
>
> > On Feb 11, 1:34 pm, Julius Spencer <jul...@msa.co.nz> wrote:
> >> Hi,
>
> >> I have an IntentService which syncs data from a server and takes a few minutes. The operation is database intensive locally (SQLite).
>
> >> I would like the user to be able to continue to use the application while the sync operation is going which involves the odd write to the database.
>
> >> Currently I'm getting "database is locked" errors. Has anyone come across this issue before and solved it?
>
> >> Regards,
> >> Julius.
>
> > --
> > 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
--
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
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home