Книга: Beginning Android

Step #4: Update the Manifest

Step #4: Update the Manifest

The glue tying the content-provider implementation to the rest of your application resides in your AndroidManifest.xml file. Simply add a provider element as a child of the <application> element:

<provider
 android:name=".Provider"
 android:authorities="com.commonsware.android.tourit.Provider" />

The android:name property is the name of the content-provider class, with a leading dot to indicate it is in the stock namespace for this application’s classes (just like you use with activities).

The android:authorities property should be a semicolon-delimited list of the authority values supported by the content provider. Recall, from earlier in this chapter, that each content Uri is made up of a scheme, an authority, a data type path, and an instance identifier. Each authority from each CONTENT_URI value should be included in the android:authorities list.

Now when Android encounters a content Uri, it can sift through the providers registered through manifests to find a matching authority. That tells Android which application and class implements the content provider, and from there Android can bridge between the calling activity and the content provider being called.

Оглавление книги


Генерация: 1.160. Запросов К БД/Cache: 3 / 1
поделиться
Вверх Вниз