On Sun, Feb 27, 2011 at 4:51 PM, Jake Colman <[email protected]> wrote:
> Getting back to the original topic, so a Content Provider is a good
> paradigm to use across the board even if the database is only meant to
> be used internally?

Kostya is pro-ContentProvider. I'm far less of a fan. Notably:

-- Data-change notification is helpful, and becomes increasingly
helpful with more complex applications. Simple apps, though, can just
requery their Cursors when they do a database change, and result is a
savings in code complexity, since ContentProviders don't write
themselves.

-- Data URls are no more useful than other forms of primary key,
except in relatively unusual circumstances (e.g., the recipient of the
Uri really isn't using the Uri but is merely passing it along to
activities that are keyed to the ContentProvider's MIME type).

The costs of a ContentProvider are:

-- You leak database connections (i.e., there is no place to close
your SQLiteDatabase).

-- The limited API that Kostya mentions, so much of makes a relational
database worthwhile is tossed out.

-- They are *world readable and writable by default*, so developers
that fail to put android:exported="false" on their <provider> elements
in the manifest make their data available for all other apps on the
device, purely by accident.

If you like the benefits and don't mind the costs, feel free to use a
ContentProvider. It's one of the more contentious architectural areas
in Android, with its proponents and detractors, so on the whole I
don't think there is a consensus "right" or "wrong" answer.

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

Android 3.0 Programming Books: http://commonsware.com/books

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