Resolving ContentProvider URLs
An Android ContentProvider
uses URLs to identify data. Typically, you can use a URL to identify a specific piece of data, such as a single reminder, or all reminders in your database. If you store other types of data there, you can use URLs for them, too.
In your application, you use two kinds of URLs — content://com.dummies.android.taskreminder.ReminderProvider/reminder
to retrieve a list of all reminders in your database or content://com.dummies.android.taskreminder.ReminderProvider/reminder/9
to retrieve a specific reminder from the database (in this case the reminder with the ID of 9).
These content provider URLs are undoubtedly similar to the URLs you’re already familiar with. Their main differences are described in this list:
content://: A ContentProvider
begins with content://
rather than with http://
.
com.dummies.android.taskreminder.ReminderProvider: The second part of the URL identifies the authority (the ReminderProvider
ContentProvider
) of the content. Though this string can be virtually anything, convention dictates using the fully qualified name of your ContentProvider
.
reminder: The third part of the URL identifies the path — in this case, ...
Get Android Application Development For Dummies, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.