1 page.title=<provider> 2 parent.title=The AndroidManifest.xml File 3 parent.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 36 access to data managed by the application. All content providers that 37 are part of the application must be represented by {@code <provider>} 38 elements in the manifest file. The system cannot see, and therefore will 39 not run, any that are not declared. (You need to declare only 40 those content providers that you develop as part of your application, 41 not those developed by others that your application uses.) 42 43 <p> 44 The Android system identifies content providers by the authority part 45 of a {@code content:} URI. For example, suppose that the following URI 46 is passed to <code>{@link android.content.ContentResolver#query 47 ContentResolver.query()}</code>: 48 49 <p style="margin-left: 2em">{@code content://com.example.project.healthcareprovider/nurses/rn}</p> 50 51 <p> 52 The {@code content:} scheme identifies the data as belonging to a content 53 provider and the authority ({@code com.example.project.healthcareprovider}) 54 identifies the particular provider. The authority therefore must be unique. 55 Typically, as in this example, it's the fully qualified name of a 56 ContentProvider subclass. The path part of a URI may be used by a content 57 provider to identify particular data subsets, but those paths are not 58 declared in the manifest. 59 </p> 60 61 <p> 62 For 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 70 of the content provider. 71 Multiple authorities are listed by separating their names with a semicolon. 72 To avoid conflicts, authority names should use a Java-style naming convention 73 (such as {@code com.example.provider.cartoonprovider}). Typically, it's the name 74 of the ContentProvider subclass. 75 76 <p> 77 There 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 83 is "{@code true}". 84 85 <p> 86 The <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 88 application components, including content providers. The 89 <code><a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code> and {@code <provider>} 90 attributes must both be "{@code true}" (as they both 91 are 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 97 applications — "{@code true}" if it can be, and "{@code false}" if not. 98 If "{@code false}", the provider is available only to components of the 99 same application or applications with the same user ID. The default value 100 is "{@code true}". 101 102 <p> 103 You 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 109 access the content provider's data can be granted permission to do so, 110 temporarily 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. 116 If "{@code true}", permission can be granted to any of the content 117 provider's data. If "{@code false}", permission can be granted only 118 to the data subsets listed in 119 <code><a href="{@docRoot}guide/topics/manifest/grant-uri-permission-element.html"><grant-uri-permission></a></code> subelements, 120 if any. The default value is "{@code false}". 121 122 <p> 123 Granting permission is a way of giving an application component one-time 124 access to data protected by a permission. For example, when an e-mail 125 message contains an attachment, the mail application may call upon the 126 appropriate viewer to open it, even though the viewer doesn't have general 127 permission to look at all the content provider's data. 128 </p> 129 130 <p> 131 In such cases, permission is granted by 132 <code>{@link android.content.Intent#FLAG_GRANT_READ_URI_PERMISSION}</code> 133 and <code>{@link android.content.Intent#FLAG_GRANT_WRITE_URI_PERMISSION}</code> 134 flags in the Intent object that activates the component. For example, the 135 mail application might put {@code FLAG_GRANT_READ_URI_PERMISSION} in the 136 Intent passed to {@code Context.startActivity()}. The permission is specific 137 to the URI in the Intent. 138 </p> 139 140 <p> 141 If you enable this feature, either by setting this attribute to "{@code true}" 142 or by defining <code><a href="{@docRoot}guide/topics/manifest/grant-uri-permission-element.html"><grant-uri-permission></a></code> 143 subelements, you must call 144 <code>{@link android.content.Context#revokeUriPermission 145 Context.revokeUriPermission()}</code> when a covered URI is deleted from 146 the provider. 147 </p> 148 149 <p> 150 See also the <code><a href="{@docRoot}guide/topics/manifest/grant-uri-permission-element.html"><grant-uri-permission></a></code> 151 element. 152 </p></dd> 153 154 <dt><a name="icon"></a>{@code android:icon}</dt> 155 <dd>An icon representing the content provider. 156 This attribute must be set as a reference to a drawable resource containing 157 the image definition. If it is not set, the icon specified for the application 158 as a whole is used instead (see the <code><a href="{@docRoot}guide/topics/manifest/application-element.html"><application></a></code> 159 element'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, 163 relative to other content providers hosted by the same process. 164 When there are dependencies among content providers, setting this 165 attribute for each of them ensures that they are created in the order 166 required by those dependencies. The value is a simple integer, 167 with 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. 171 If this attribute is not set, the label set for the application as a whole is 172 used 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> 176 The label should be set as a reference to a string resource, so that 177 it can be localized like other strings in the user interface. 178 However, as a convenience while you're developing the application, 179 it 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 184 every client process — "{@code true}" if instances can run in multiple 185 processes, and "{@code false}" if not. The default value is "{@code false}". 186 187 <p> 188 Normally, a content provider is instantiated in the process of the 189 application that defined it. However, if this flag is set to "{@code true}", 190 the system can create an instance in every process where there's a client 191 that wants to interact with it, thus avoiding the overhead of interprocess 192 communication. 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 198 class name (such as, "{@code com.example.project.TransportationProvider}"). 199 However, as a shorthand, if the first character of the name is a period, 200 it 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> 204 There 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 210 content provider's data. This attribute is a convenient way of setting a 211 single 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 214 over this one. If the <code><a href="{@docRoot}guide/topics/manifest/provider-element.html#rprmsn">readPermission</a></code> 215 attribute is also set, it controls access for querying the content provider. 216 And if the <code><a href="#wprmsn">writePermission</a></code> attribute is set, 217 it controls access for modifying the provider's data. 218 219 <p> 220 For more information on permissions, see the 221 <a href="{@docRoot}guide/topics/manifest/manifest-intro.html#sectperm">Permissions</a> 222 section in the introduction and a separate document, 223 <a href="{@docRoot}guide/topics/security/security.html">Security and 224 Permissions</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, 229 all components of an application run in the default process created for the 230 application. 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> 233 attribute can set a different 234 default for all components. But each component can override the default 235 with its own {@code process} attribute, allowing you to spread your 236 application across multiple processes. 237 238 <p> 239 If the name assigned to this attribute begins with a colon (':'), a new 240 process, private to the application, is created when it's needed and 241 the activity runs in that process. 242 If the process name begins with a lowercase character, the activity will run 243 in a global process of that name, provided that it has permission to do so. 244 This allows components in different applications to share a process, reducing 245 resource 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. 250 See 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 255 is to be synchronized with data on a server — "{@code true}" 256 if 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 260 controlled by the content provider. 261 See 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