English Original: http://developer.android.com/guide/topics/manifest/provider-element.html
Acquisition (update) Date: 2014-7-1
Moved from the original blog: http://blog.sina.com.cn/s/blog_48d491300100zmv5.html
-
-
Grammar:
-
<providerandroid: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>
-
-
Included in:
-
-
<application>
-
-
can include:
-
-
<meta-data>
<grant-uri-permission>
<path-permission>
-
-
Description
-
Declares a Content Provider component. Content Provider is
ContentProvider
Sub-class that provides structured access to the data that the application manages. All Content Provider for the application must be in the Manifest file
<provider>
element, otherwise, the system is ignored and will not run Content Provider.
You only need to declare the content Provider that the application contains. Content Provider that belong to other applications and are used by this program do not need to be declared.
The Android system uses the authority portion of the content URI to hold a reference to the content Provider. For example, suppose you want to access a Content Provider that stores information about medical personnel. Here the ContentResolver.query()
method is called, and the following URI identifies the Content Provider as one of the parameters:
Content://com.example.project.healthcareprovider/nurses/rn
content:
The scheme section indicates that this is a URI that points to Android Content Provider. The Authority section com.example.project.healthcareprovider
identifies the Content Provider itself. The Android system will look for the authority information in the known Provider and authority lists. nurses/rn
A string is a path information that Content Provider can use to identify a portion of the data.
Note that when you <provider>
define Content Provider in an element, do not android:name
include scheme and path information in it, as long as the authority is available.
For more information about developing and using content Provider, see the API Guide content Provider.
-
-
Property:
-
-
-
android:authorities
-
-
one or more URI authority lists that identify the data provided within the Content Provider. Multiple authority names are separated by semicolons. To avoid conflicts, authority names should use Java-style naming conventions (for example
com.example.provider.cartoonprovider
). In general, it is the subclass name that implements the Content Provider
ContentProvider
.
There is no default value. At least one authority must be specified.
-
-
android:enabled
-
-
Content Provider can be instantiated by the system-"" Yes, ""
true
false
is not allowed. The default value is "
true
".
<application>
Elements have their own enabled
properties, which apply to all internal components of the application, including the Content Provider. To allow the use of the content provider, <application>
and <provider>
the property must be set to " true
" (all the default values). If either of these is " false
", then the Content Provider will be disabled and it will not be instantiated.
-
-
android:exported
-
-
This Content Provider can be used by other applications:
- "
true
": Yes. Any application can access this content Provider through a URI and is subject to the permission requirements of the content Provider claim.
- "
false
": No, you can't. By setting android:exported="false"
, you can restrict the Content Provider in this application. Only those applications with the same user ID will be able to access it.
For android:minSdkVersion
android:targetSdkVersion
applications with or less than equals "16"
, the default value is "true". For these two attribute values for "17"
the above application, the default value is "false"
.
-
-
android:grantUriPermissions
-
Is it possible to temporarily surpass
readPermission
、
writePermission
And
permission
attribute, giving the usual permission to access Content Provider data-"
true
"Can authorize,"
false
"Not to." If set to "
true
, you can grant access to all of the data for the Content Provider. If set to "
false
"That's the only
<grant-uri-permission>
The subset of data (if any) that is listed in the child element is authorized. The default value is "
false
”。
The authorization mechanism enables program components to make one-time access to data that is protected by rights. For example, if an e-mail contains an attachment, the mail program may call the appropriate viewer to open the attachment, even if the viewer does not normally have permission to view all of the Content Provider's data.
At this point, you can authorize by setting the Intent object's FLAG_GRANT_READ_URI_PERMISSION
and flag bits of the boot component FLAG_GRANT_WRITE_URI_PERMISSION
. For example, the mail program can be Context.startActivity()
set in the incoming Intent FLAG_GRANT_READ_URI_PERMISSION
. The permission is specified to grant the URI in the Intent.
If the feature of this temporary authorization is enabled, whether this property is set to " true
or a child element is defined, <grant-uri-permission>
it must be called when the URI involved is to be removed from the Content Provider Context.revokeUriPermission()
.
See <grant-uri-permission>
elements.
-
-
android:icon
-
-
represents the icon for the Content Provider. This property must be set to a reference to the drawable resource that contains the definition of the picture. If this property is not set, the icon for the global application is used instead. (see
<application>
attributes of an element
icon
).
-
-
android:initOrder
-
The
-
instantiation order of this Content Provider relative to other content Provider in the same process. If there is a dependency between multiple content Provider, you can use this property to ensure that you create individual content Provider according to the required dependencies. The value of this property is an integer, and the higher the value, the first it is initialized.
-
-
android:label
-
-
text label for Content Provider for users to read. If this property is not set, the global Application text label is used instead (see
<application>
attributes of the element
label
).
This label should be set as a reference to a string resource so that it can be localized like any other string in the user interface. However, it can also be set directly to a string for ease of application development.
-
-
android:multiprocess
-
-
Whether you can create an instance of the Content Provider in each client process-"
true
" means that you can run the instance in multiple processes, "
false
" means no. The default value is "
false
".
Typically, Content Provider is instantiated in the process of the application that defines it. However, if this property is set to " true
", then the system can create an instance in each of the processes in which the client program needs to use it, thus avoiding the overhead of interprocess communication.
-
-
android:name
-
-
Implements the class name of the Content Provider, which is
ContentProvider
the subclass. This should be a fully qualified class name (such as "
com.example.project.TransportationProvider
"). However, as the abbreviation, if the first character is a period, the
<manifest>
package name specified by the element is automatically preceded by the name.
There is no default value. The name must be specified.
-
-
android:permission
-
The
-
name of the permission required for the client to read and write data in the Content Provider. This property provides a quick way to set read and write permissions once. However, the
readPermission
and
writePermission
attributes take precedence over this setting. If a property is set at the same time
readPermission
, it controls the read of the Content Provider. If a property is set
writePermission
, it also controls modifications to the Content Provider data.
For more information about permissions, see the Permissions section of Manifest Introduction article and another document security and permissions.
-
-
android:process
-
-
The name of the process running Content Provider. Typically, all components of an application run in the default process at the time of creation. The name of the process is the same as the package name.
<application>
the attributes of an element
process
can also have different default processes set for each component. But each component can also
process
override the default process name with its own properties, allowing the program to run across multiple processes.
If the name set by this property begins with a colon (': '), a process that is private to the program is created if necessary, and Content Provider will run in this new process. If the process name starts with a lowercase letter, the content provider runs in a global process named this name and gives the appropriate access. This allows multiple components of different applications to share the same process, reducing the use of resources.
-
-
android:readPermission
-
The
-
permissions required to query the Content Provider client. See also
permission
and
writePermission
properties.
-
-
android:syncable
-
-
whether the data that the Content Provider controls needs to be synchronized with a server-"
true
" means synchronization is required, ""
false
indicates no need.
-
-
android:writePermission
-
The
-
permissions required to modify the client for the Content Provider data. See
permission
and
readPermission
properties.