Introduction to the URI in Android

Source: Internet
Author: User
Tags resource

As far as the Android platform is concerned, the URI is mainly divided into three parts: scheme, authority and path. Among them authority is divided into host and port. The format is as follows:

Scheme://host:port/path

As a practical example:

Content://com.example.project:200/folder/subfolder/etc

\---------/  \---------------------------/ \---/ \--------------------------/

Scheme Host Port Path

\--------------------------------/

Authority

Now you should know the meaning of those attributes in data flag, look at the data flag

<data android:host= "string"

Android:mimetype= "string"

Android:path= "string"

Android:pathpattern= "string"

android:pathprefix= "string"

Android:port= "string"

Android:scheme= "string"/>

1.Uri

Generic resource Identifier (Universal Resource Identifier, "URI").

The URI represents the data to be manipulated, and each resource available on Android-images, video clips, and so on-can be represented by a URI.

A URI generally consists of three parts:

The naming mechanism for accessing resources.

Host name where the resource is stored.

The name of the resource itself, represented by the path.

The Android URI consists of the following three parts: "content://", the path to the data, the ID (optional)

For some examples, such as:

Uri:content://contacts/people for all contact persons

URI:CONTENT://CONTACTS/PEOPLE/5 of a contact person

All pictures uri:content://media/external

The URI:CONTENT://MEDIA/EXTERNAL/IMAGES/MEDIA/4 of a picture

We often need to parse the URI and get the data from the URI.

The Android system provides two tool classes for manipulating URIs, Urimatcher and Contenturis respectively.

Although these two classes are not very important, mastering their use will facilitate our development work.

Let's take a look at the role of these two classes together.

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.