Thanks Kostya,

Actually, I don't need to expose my data. I'm using a ContentProvider
because I'm trying to implement the REST architecture suggested by
Virgil Dobjanschi on Google I/O:

http://www.google.com/events/io/2010/sessions/developing-RESTful-android-apps.html

Though, I have complex entities in a normalized database, so I need
transactions in order to insert parts of a single entity on their
respective tables and do some data validation (say queries) between
these insert operations. Is there a better solution for that?


On Nov 4, 2:42 pm, Kostya Vasilyev <[email protected]> wrote:
> My two cents: don't go through your own ContentProvider unless you need to.
>
> Use ContentProvider for exporting data to other apps, or, within the
> app, for very specific URIs that should trigger UI updates.
>
> For the rest of the data, that is, those db ops that don't need to
> trigger UI updates, going directly to the database APIs gives better
> flexibility, performance, and control (wrt. change notifications).
>
> -- Kostya
>
> 04.11.2011 20:36, Pepijn Van Eeckhoudt пишет:
>
>
>
>
>
>
>
>
>
> > Override ContentProvider#applyBatch, start a transaction on your
> > database, apply all the operations and then commit (or rollback) the
> > transaction. The default implementation delegates each operation to
> > the corresponding ContentProvider method so you can probably do this as:
>
> > startTransaction
> > try {
> > super.applyBatch
> > setTransactionSuccesful
> > } finally {
> > endTransaction
> > }
>
> > Pepijn
>
> > On 03/11/2011 20:59, Flávio Faria wrote:
> >> Hi guys,
>
> >> I have a ContentProvider in my app that wraps an SQLite database. I'm
> >> wondering what is the best way to call insert(), update(), delete()
> >> and query() inside a database transaction. Is it possible? Is there
> >> any workaround? bulkInsert() doesn't help since it only makes insert()
> >> calls.
>
> >> Thanks.
>
> --
> Kostya Vasilyev

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

Reply via email to