Android manifest XML provider tag. android:authorities

Eae picture Eae · May 31, 2013 · Viewed 16.9k times · Source

I have been going through the NotePad sample application for android-17 when I came across this tag in the manifest XML file:

    <provider android:name="NotePadProvider"
        android:authorities="com.google.provider.NotePad"
        android:exported="false">
        <grant-uri-permission android:pathPattern=".*" />
    </provider>

I looked up the defenition and I see that com.google.provider.NotePad is being listed as one of the authorities for the provider. I am assuming that NotePadProvider is referencing the class NotePadProvider defined in the NotePadProvider.java file but I want to ask if that is really the case to make sure I am on the right track.

Also I am wondering what exactly is com.google.provider.NotePad and where is it defined and what is the purpose of com.google.provider.NotePad and what does it mean that com.google.provider.NotePad is the authority for the provider exactly.

Answer

Sam R. picture Sam R. · May 31, 2013

That's the ContentProvider.

Content providers are one of the primary building blocks of Android applications, providing content to applications. They encapsulate data and provide it to applications through the single ContentResolver interface. A content provider is only required if you need to share data between multiple applications. For example, the contacts data is used by multiple applications and must be stored in a content provider. If you don't need to share data amongst multiple applications you can use a database directly via SQLiteDatabase.

Actually, com.google.provider.NotePad is a class that implements the ContentProvider.

From <provider>:

android:authorities A list of one or more URI authorities that identify data offered by the content provider. Multiple authorities are listed by separating their names with a semicolon. To avoid conflicts, authority names should use a Java-style naming convention (such as com.example.provider.cartoonprovider). Typically, it's the name of the ContentProvider subclass that implements the provider