On Sat, Nov 5, 2011 at 10:13 AM, Kostya Vasilyev <kmans...@gmail.com> wrote:
> 2) Serve data to the UI via a CP, to leverage Android's notificaitons.
> Nothing changes here, no need for broadcast receivers. Perform other
> operations bypassing the CP, dealing directly with the DB.

Um, I'm not sure how that works. If you insert a row in the DB
directly, the CP will not be notified via the ContentObserver.

> Another thought is this: a CP URI doesn't have to be mapped one to one to a
> particular table. A CP implementation can work with multiple tables inside a
> single ContentResolver.<insert/update/query/delete>() call made by a client,
> and can wrap them in a DB transaction.
>
> So that's another path to take, if you really want to always access all your
> data through a CP: put the logic of mapping between logical entires and
> tables inside the CP, treating CP operations as dealing with logical
> entities rather than tables.

In this respect, using a CP is not too dissimilar from creating a
REST-based server. Just as the REST URL patterns may not line up
1-to-1 with tables, the CP Uri patterns do not have to line up 1-to-1
with tables. CPs are not as flexible, though, since you're stuck with
a flat ContentValues as your data structure.

Also, if you use content providers, be sure to mark your
ContentProvider as *NOT EXPORTED* in the manifest
(android:exported="false"), as it is exported by default, meaning your
data is wide open for anyone to access and manipulate.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Warescription: Three Android Books, Plus Updates, One Low Price!

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