AndroidManifest. xml file description (provider)

Source: Internet
Author: User

SYNTAX (SYNTAX ):

<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 (contained in ):

<Application>

Can contain ):

<Meta-data>

<Grant-uri-permission>

<Path-permission>

DESCRIPTION ):

This element is used to declare a content provider, which corresponds to a subclass of the ContentProvider class. It provides structured access to data managed by applications. All content providers used by the application must be declared by the <provider> element in its inventory file. For content providers that are not declared in the list, the system does not see or run. (You only need to declare those content providers that are developed as part of the application, rather than those that are used by other people to develop the application ).

The Android system uses the content: URI authorization part to identify the content provider. For example, assume that the following URI is to be passed to the ContentResolver. query () method:

Content: // com. example. project. healthcareprovider/nurses/rn

Content: indicates that the data belongs to the content provider. Authorization (com. example. project. healthcareprovider) indicates a specific provider. Therefore, the authorization must be unique. In general, as in this example, authorization is the name of a complete ContentProvider subclass. The URI path is used by the content provider to identify a specific data subset, but those paths are not declared in the list file.

ATTRIBUTES (ATTRIBUTES ):

Android: authorities

Identifies the authorization list of data Uris within the scope of the content provider. When there are multiple authorizations, use a semicolon to separate Each authorization. To avoid conflicts, the authorization name should use Java-style naming rules (for example, com. example. provider. cartoonprovider ). Generally, the ContentProvider subclass name is used to set this attribute.

This attribute has no default value. At least one authorization must be specified.

Android: enabled

This attribute is used to specify whether the content provider can be installed by the system. If it is set to true, It can be installed; otherwise, it cannot be installed. The default value is true.

<Application> An element has its own enabled attribute, which is applied to all application components, including the content provisioner. The enabled attribute of <application> and <provider> must be set to true (both of them have the default value true ). If either of them is set to false, the provisioner will not be installed.

Android: exported

This attribute is used to specify whether the content provider can be used by other application components. If it is set to true, it can be used; otherwise, it cannot be used. If it is set to false, the provider is only valid for applications with the same name or applications with the same user ID. The default value is true.

Although this attribute can be used to expose the content provisioner, the permission attribute is still used to restrict access to it.

Android: grantUriPermission

This attribute is used to set whether access permissions can be granted to visitors who do not have access to the data provided by the content. This permission is temporary, it will overcome the restrictions set by readPermission, writePermission, and permission attributes. If this attribute is set to true, the access permission can be granted to the visitor. Otherwise, no access permission is granted to the visitor. If it is set to true, the permission can be temporarily granted to any data of the content provider. If it is set to false, the permission can only be granted to the subset listed in the <gran-uri-permission> subelement. The default value is false.

This authorization is a one-time access to data protected by permissions provided by the application. For example, when an e-mail contains an attachment, the mail application can call an appropriate browser to open the attachment, even if the browser does not have the permission to view all the content provider data.

In this scenario, permissions are granted by the FLAG_GRANT_READ_URI_PERMISSION and FLAG_GRANT_WRITE_URI_PERMISSION tags in the Intent object of the component. For example, the mail application can put the FLAG_GRANT_READ_URI_PERMISSION tag in the Intent parameter passed to the Context. startActivity () method. In this way, the permission is granted to the URI specified in the Intent object.

If you want to enable this function, you can either set this attribute to true or define the <grant-uri-permission> sub-element. When you switch the RUI, context must be called. the revokeUriPermission () method deletes the permission from the provider.

Android: icon

This attribute is used to define an icon that represents the content provider. It must reference a customizable resource that contains image definitions. If this attribute is not set, it will be replaced by the icon attribute value of the <application> element of the application.

Android: initOrder

This attribute defines the order in which the content provider should be instantiated, which is relative to other content providers owned by the same process. When the content providers have mutual dependencies, you need to set this attribute to ensure that they can be created in the order of their dependencies. This attribute value is a simple integer, and large numbers must be initialized first.

Android: label

This attribute is used to define a user-readable tag for the content provider. If this attribute is not set, it will be replaced by the label attribute value of the <application> element.

This label should reference a string resource to set so that it can be localized like strings in other user interfaces. However, to facilitate application development, the native string can be used to set this attribute, but the string resource must be referenced during official release.

Android: multiprocess

This attribute is used to set whether a content provider instance can be created in each client process that uses the content provider. If it is set to true, this can create an instance in each of its client processes. Otherwise, it cannot. The default value is false.

Generally, the content provider is instantiated in the process that defines its application. However, if this attribute is set to true, the system will be able to create a content provider instance in each client process to interact with the content provider, this avoids the overhead of inter-process communication.

Android: name

This attribute defines the name of the implementation class of the content provider. It is a subclass of the ContentProvider class. This attribute should be set using the complete Java class name (for example, com. example. project. TransportationProvider ). However, you can also use abbreviations (for example,. TransporttationProvider). In this case, the system uses a combination of the package name specified in the <manifest> element and the abbreviated name to identify the content provider.

This property has no default value. You must set a name for this property.

Android: permission

This attribute is used to set the name of the required permission when the client reads and writes the data of the provider. This attribute provides a convenient way to set both read and write permissions. However, the priority of the readPermission and writePermission attributes is higher than that of the attributes. If the readPermission attribute is set, it controls the query access to the content provider. If the writePermission attribute is set, it controls access to the data modification of the content provider.

Android: process

This attribute defines the name of the process in which the content provider should run. Generally, all components of an application run in the default process created for the application. It has the same name as the application package. <Application> the process attribute of an element can set a different default process for all its components. However, each component can overwrite this default setting with its own process attribute, allowing the application to be separated into different processes.

If the attribute value starts with ":", the system will create a new private process for the application when the provider is required, and the corresponding Activity should also run in that private process. If it starts with a lower-case letter, the Activity runs in a global process named after this attribute value. It provides access permissions to the content provider. This allows components of different applications to share the process, thus reducing the use of system resources.

Android: readPermission

This attribute is used to set the required permissions on the client when querying the data of the content provider.

Android: syncable

This attribute is used to set whether the data under the control of the content provider needs to be synchronized with the data on the server. If it is set to true, it needs to be synchronized; otherwise, no synchronization is required.

Android: writePermission

This attribute is used to set the permissions required by the client when modifying the data of the content provider.

INTRODUCED version (introduced in ):

API Level 1

 


From FireOfStar's column

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.