1page.title=<provider> 2parent.title=The AndroidManifest.xml File 3parent.link=manifest-intro.html 4@jd:body 5 6<dl class="xml"> 7<dt>syntax:</dt> 8<dd><pre class="stx"><provider android:<a href="#auth">authorities</a>="<i>list</i>" 9 android:<a href="#enabled">enabled</a>=["true" | "false"] 10 android:<a href="#exported">exported</a>=["true" | "false"] 11 android:<a href="#gprmsn">grantUriPermissions</a>=["true" | "false"] 12 android:<a href="#icon">icon</a>="<i>drawable resource</i>" 13 android:<a href="#init">initOrder</a>="<i>integer</i>" 14 android:<a href="#label">label</a>="<i>string resource</i>" 15 android:<a href="#multi">multiprocess</a>=["true" | "false"] 16 android:<a href="#nm">name</a>="<i>string</i>" 17 android:<a href="#prmsn">permission</a>="<i>string</i>" 18 android:<a href="#proc">process</a>="<i>string</i>" 19 android:<a href="#rprmsn">readPermission</a>="<i>string</i>" 20 android:<a href="#sync">syncable</a>=["true" | "false"] 21 android:<a href="#wprmsn">writePermission</a>="<i>string</i>" > 22 . . . 23</provider></pre></dd> 24 25<dt>contained in:</dt> 26<dd><code><a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code></dd> 27 28<dt>can contain:</dt> 29<dd><code><a href="{@docRoot}guide/topics/manifest/meta-data-element.html"><meta-data></a></code> 30<br/><code><a href="{@docRoot}guide/topics/manifest/grant-uri-permission-element.html"><grant-uri-permission></a></code> 31<br/><code><a href="{@docRoot}guide/topics/manifest/path-permission-element.html"><path-permission></a></code></dd> 32 33<dt>description:</dt> 34<dd>Declares a content provider — a subclass of 35{@link android.content.ContentProvider} — that supplies structured 36access to data managed by the application. All content providers that 37are part of the application must be represented by {@code <provider>} 38elements in the manifest file. The system cannot see, and therefore will 39not run, any that are not declared. (You need to declare only 40those content providers that you develop as part of your application, 41not those developed by others that your application uses.) 42 43<p> 44The Android system identifies content providers by the authority part 45 of a {@code content:} URI. For example, suppose that the following URI 46is passed to <code>{@link android.content.ContentResolver#query 47ContentResolver.query()}</code>: 48 49<p style="margin-left: 2em">{@code content://com.example.project.healthcareprovider/nurses/rn}</p> 50 51<p> 52The {@code content:} scheme identifies the data as belonging to a content 53provider and the authority ({@code com.example.project.healthcareprovider}) 54identifies the particular provider. The authority therefore must be unique. 55Typically, as in this example, it's the fully qualified name of a 56ContentProvider subclass. The path part of a URI may be used by a content 57provider to identify particular data subsets, but those paths are not 58declared in the manifest. 59</p> 60 61<p> 62For information on using and developing content providers, see a separate document, 63<a href="{@docRoot}guide/topics/providers/content-providers.html">Content Providers</a>. 64</p></dd> 65 66<dt>attributes:</dt> 67<dd><dl class="attr"> 68<dt><a name="auth"></a>{@code android:authorities}</dt> 69<dd>A list of one or more URI authorities that identify data under the purview 70of the content provider. 71Multiple authorities are listed by separating their names with a semicolon. 72To avoid conflicts, authority names should use a Java-style naming convention 73(such as {@code com.example.provider.cartoonprovider}). Typically, it's the name 74of the ContentProvider subclass. 75 76<p> 77There is no default. At least one authority must be specified. 78</p></dd> 79 80<dt><a name="enabled"></a>{@code android:enabled}</dt> 81<dd>Whether or not the content provider can be instantiated by the system — 82"{@code true}" if it can be, and "{@code false}" if not. The default value 83is "{@code true}". 84 85<p> 86The <code><a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code> element has its own 87<code><a href="{@docRoot}guide/topics/manifest/application-element.html#enabled">enabled</a></code> attribute that applies to all 88application components, including content providers. The 89<code><a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code> and {@code <provider>} 90attributes must both be "{@code true}" (as they both 91are by default) for the content provider to be enabled. If either is 92"{@code false}", the provider is disabled; it cannot be instantiated. 93</p></dd> 94 95<dt><a name="exported"></a>{@code android:exported}</dt> 96<dd>Whether or not the content provider can be used by components of other 97applications — "{@code true}" if it can be, and "{@code false}" if not. 98If "{@code false}", the provider is available only to components of the 99same application or applications with the same user ID. The default value 100is "{@code true}". 101 102<p> 103You can export a content provider but still limit access to it with the 104<code><a href="{@docRoot}guide/topics/manifest/provider-element.html#prmsn">permission</a></code> attribute. 105</p></dd> 106 107<dt><a name="gprmsn"></a>{@code android:grantUriPermissions}</dt> 108<dd>Whether or not those who ordinarily would not have permission to 109access the content provider's data can be granted permission to do so, 110temporarily overcoming the restriction imposed by the 111<code><a href="{@docRoot}guide/topics/manifest/provider-element.html#rprmsn">readPermission</a></code>, 112<code><a href="{@docRoot}guide/topics/manifest/provider-element.html#wprmsn">writePermission</a></code>, and 113<code><a href="{@docRoot}guide/topics/manifest/provider-element.html#prmsn">permission</a></code> attributes 114— 115"{@code true}" if permission can be granted, and "{@code false}" if not. 116If "{@code true}", permission can be granted to any of the content 117provider's data. If "{@code false}", permission can be granted only 118to the data subsets listed in 119<code><a href="{@docRoot}guide/topics/manifest/grant-uri-permission-element.html"><grant-uri-permission></a></code> subelements, 120if any. The default value is "{@code false}". 121 122<p> 123Granting permission is a way of giving an application component one-time 124access to data protected by a permission. For example, when an e-mail 125message contains an attachment, the mail application may call upon the 126appropriate viewer to open it, even though the viewer doesn't have general 127permission to look at all the content provider's data. 128</p> 129 130<p> 131In such cases, permission is granted by 132<code>{@link android.content.Intent#FLAG_GRANT_READ_URI_PERMISSION}</code> 133and <code>{@link android.content.Intent#FLAG_GRANT_WRITE_URI_PERMISSION}</code> 134flags in the Intent object that activates the component. For example, the 135mail application might put {@code FLAG_GRANT_READ_URI_PERMISSION} in the 136Intent passed to {@code Context.startActivity()}. The permission is specific 137to the URI in the Intent. 138</p> 139 140<p> 141If you enable this feature, either by setting this attribute to "{@code true}" 142or by defining <code><a href="{@docRoot}guide/topics/manifest/grant-uri-permission-element.html"><grant-uri-permission></a></code> 143subelements, you must call 144<code>{@link android.content.Context#revokeUriPermission 145Context.revokeUriPermission()}</code> when a covered URI is deleted from 146the provider. 147</p> 148 149<p> 150See also the <code><a href="{@docRoot}guide/topics/manifest/grant-uri-permission-element.html"><grant-uri-permission></a></code> 151element. 152</p></dd> 153 154<dt><a name="icon"></a>{@code android:icon}</dt> 155<dd>An icon representing the content provider. 156This attribute must be set as a reference to a drawable resource containing 157the image definition. If it is not set, the icon specified for the application 158as a whole is used instead (see the <code><a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code> 159element's <code><a href="{@docRoot}guide/topics/manifest/application-element.html#icon">icon</a></code> attribute).</dd> 160 161<dt><a name="init"></a>{@code android:initOrder}</dt> 162<dd>The order in which the content provider should be instantiated, 163relative to other content providers hosted by the same process. 164When there are dependencies among content providers, setting this 165attribute for each of them ensures that they are created in the order 166required by those dependencies. The value is a simple integer, 167with higher numbers being initialized first.</dd> 168 169<dt><a name="label"></a>{@code android:label}</dt> 170<dd>A user-readable label for the content provided. 171If this attribute is not set, the label set for the application as a whole is 172used instead (see the <code><a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code> element's 173<code><a href="{@docRoot}guide/topics/manifest/application-element.html#label">label</a></code> attribute). 174 175<p> 176The label should be set as a reference to a string resource, so that 177it can be localized like other strings in the user interface. 178However, as a convenience while you're developing the application, 179it can also be set as a raw string. 180</p></dd> 181 182<dt><a name="multi"></a>{@code android:multiprocess}</dt> 183<dd>Whether or not an instance of the content provider can be created in 184every client process — "{@code true}" if instances can run in multiple 185processes, and "{@code false}" if not. The default value is "{@code false}". 186 187<p> 188Normally, a content provider is instantiated in the process of the 189application that defined it. However, if this flag is set to "{@code true}", 190the system can create an instance in every process where there's a client 191that wants to interact with it, thus avoiding the overhead of interprocess 192communication. 193</p></dd> 194 195<dt><a name="nm"></a>{@code android:name}</dt> 196<dd>The name of the class that implements the content provider, a subclass of 197{@link android.content.ContentProvider}. This should be a fully qualified 198class name (such as, "{@code com.example.project.TransportationProvider}"). 199However, as a shorthand, if the first character of the name is a period, 200it is appended to the package name specified in the 201<code><a href="{@docRoot}guide/topics/manifest/manifest-element.html"><manifest></a></code> element. 202 203<p> 204There is no default. The name must be specified. 205</p></dd> 206 207 208<dt><a name="prmsn"></a>{@code android:permission}</dt> 209<dd>The name of a permission that clients must have to read or write the 210content provider's data. This attribute is a convenient way of setting a 211single permission for both reading and writing. However, the 212<code><a href="#rprmsn">readPermission</a></code> and 213<code><a href="#wprmsn">writePermission</a></code> attributes take precedence 214over this one. If the <code><a href="{@docRoot}guide/topics/manifest/provider-element.html#rprmsn">readPermission</a></code> 215attribute is also set, it controls access for querying the content provider. 216And if the <code><a href="#wprmsn">writePermission</a></code> attribute is set, 217it controls access for modifying the provider's data. 218 219<p> 220For more information on permissions, see the 221<a href="{@docRoot}guide/topics/manifest/manifest-intro.html#sectperm">Permissions</a> 222section in the introduction and a separate document, 223<a href="{@docRoot}guide/topics/security/security.html">Security and 224Permissions</a>. 225</p></dd> 226 227<dt><a name="proc"></a>{@code android:process}</dt> 228<dd>The name of the process in which the content provider should run. Normally, 229all components of an application run in the default process created for the 230application. It has the same name as the application package. The 231<code><a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code> element's 232<code><a href="{@docRoot}guide/topics/manifest/application-element.html#proc">process</a></code> 233attribute can set a different 234default for all components. But each component can override the default 235with its own {@code process} attribute, allowing you to spread your 236application across multiple processes. 237 238<p> 239If the name assigned to this attribute begins with a colon (':'), a new 240process, private to the application, is created when it's needed and 241the activity runs in that process. 242If the process name begins with a lowercase character, the activity will run 243in a global process of that name, provided that it has permission to do so. 244This allows components in different applications to share a process, reducing 245resource usage. 246</p></dd> 247 248<dt><a name="rprmsn"></a>{@code android:readPermission}</dt> 249<dd>A permission that clients must have to query the content provider. 250See also the <code><a href="#prmsn">permission</a></code> and 251<code><a href="#wprmsn">writePermission</a></code> attributes.</dd> 252 253<dt><a name="sync"></a>{@code android:syncable}</dt> 254<dd>Whether or not the data under the content provider's control 255is to be synchronized with data on a server — "{@code true}" 256if it is to be synchronized, and "{@code false}" if not.</dd> 257 258<dt><a name="wprmsn"></a>{@code android:writePermission}</dt> 259<dd>A permission that clients must have to make changes to the data 260controlled by the content provider. 261See also the <code><a href="#prmsn">permission</a></code> and 262<code><a href="#rprmsn">readPermission</a></code> attributes.</dd> 263 264</dl></dd> 265 266<!-- ##api level indication## --> 267<dt>introduced in:</dt> 268<dd>API Level 1</dd> 269 270<dt>see also:</dt> 271<dd><a href="{@docRoot}guide/topics/providers/content-providers.html">Content Providers</a></dd> 272 273</dl> 274