page.title=<provider> parent.title=The AndroidManifest.xml File parent.link=manifest-intro.html @jd:body
<provider android:authorities="list" android:enabled=["true" | "false"] android:exported=["true" | "false"] android:grantUriPermissions=["true" | "false"] android:icon="drawable resource" android:initOrder="integer" android:label="string resource" android:multiprocess=["true" | "false"] android:name="string" android:permission="string" android:process="string" android:readPermission="string" android:syncable=["true" | "false"] android:writePermission="string" > . . . </provider>
<application>
<meta-data>
<grant-uri-permission>
<path-permission>
You only declare content providers that are part of your application. Content providers in other applications that you use in your application should not be declared.
The Android system stores references to content providers according to an authority string, part of the provider's content URI. For example, suppose you want to access a content provider that stores information about health care professionals. To do this, you call the method {@link android.content.ContentResolver#query ContentResolver.query()}, which among other arguments takes a URI that identifies the provider:
content://com.example.project.healthcareprovider/nurses/rn
The content:
scheme identifies the URI as a content URI pointing to
an Android content provider. The authority
com.example.project.healthcareprovider
identifies the provider itself; the
Android system looks up the authority in its list of known providers and their authorities.
The substring nurses/rn
is a path, which the content provider can use
to identify subsets of the provider data.
Notice that when you define your provider in the <provider>
element, you
don't include the scheme or the path in the android:name
argument, only the
authority.
For information on using and developing content providers, see the API Guide, Content Providers.
There is no default. At least one authority must be specified.
The <application>
element has its own
enabled
attribute that applies to all
application components, including content providers. The
<application>
and {@code
true
: The provider is available to other applications. Any application can
use the provider's content URI to access it, subject to the permissions specified for
the provider.
false
: The provider is not available to other applications. Set
android:exported="false"
to limit access to the provider to your
applications. Only applications that have the same user ID (UID) as the provider will
have access to it.
The default value is "true"
for applications that set either
android:minSdkVersion
or
android:targetSdkVersion
to
"16"
or lower. For applications that
set either of these attributes to "17"
or higher, the default is
"false"
.
You can set android:exported="false"
and still limit access to your
provider by setting permissions with the
permission
attribute.
readPermission
,
writePermission
, and
permission
attributes
—
"{@code true}" if permission can be granted, and "{@code false}" if not.
If "{@code true}", permission can be granted to any of the content
provider's data. If "{@code false}", permission can be granted only
to the data subsets listed in
<grant-uri-permission>
subelements,
if any. The default value is "{@code false}".
Granting permission is a way of giving an application component one-time access to data protected by a permission. For example, when an e-mail message contains an attachment, the mail application may call upon the appropriate viewer to open it, even though the viewer doesn't have general permission to look at all the content provider's data.
In such cases, permission is granted by
{@link android.content.Intent#FLAG_GRANT_READ_URI_PERMISSION}
and {@link android.content.Intent#FLAG_GRANT_WRITE_URI_PERMISSION}
flags in the Intent object that activates the component. For example, the
mail application might put {@code FLAG_GRANT_READ_URI_PERMISSION} in the
Intent passed to {@code Context.startActivity()}. The permission is specific
to the URI in the Intent.
If you enable this feature, either by setting this attribute to "{@code true}"
or by defining <grant-uri-permission>
subelements, you must call
{@link android.content.Context#revokeUriPermission
Context.revokeUriPermission()}
when a covered URI is deleted from
the provider.
See also the <grant-uri-permission>
element.
<application>
element's icon
attribute).<application>
element's
label
attribute).
The label should be set as a reference to a string resource, so that it can be localized like other strings in the user interface. However, as a convenience while you're developing the application, it can also be set as a raw string.
true
,
each of the app's processes has its own content provider object. If
false
, the app's processes share only one content provider object.
The default value is false
.
Setting this flag to true
may improve performance by reducing
the overhead of interprocess communication, but it also increases the memory
footprint of each process.
<manifest>
element.
There is no default. The name must be specified.
readPermission
and
writePermission
attributes take precedence
over this one. If the readPermission
attribute is also set, it controls access for querying the content provider.
And if the writePermission
attribute is set,
it controls access for modifying the provider's data.
For more information on permissions, see the Permissions section in the introduction and a separate document, Security and Permissions.
<application>
element's
process
attribute can set a different
default for all components. But each component can override the default
with its own {@code process} attribute, allowing you to spread your
application across multiple processes.
If the name assigned to this attribute begins with a colon (':'), a new process, private to the application, is created when it's needed and the activity runs in that process. If the process name begins with a lowercase character, the activity will run in a global process of that name, provided that it has permission to do so. This allows components in different applications to share a process, reducing resource usage.
permission
and
writePermission
attributes.permission
and
readPermission
attributes.