
浅析什么是uriAnalysis of what is URI.doc
11页浅析什么是 uri (Analysis of what is URI)Analysis of what is URI?Analysis of what is URI?Analysis of what is URI?1. what is URI?Each resource available on Web 一 HTML documents, images, video clips, programs, etc. - by one passUse the Universal Resource Identifier (URI) for location.URI generally consists of three parts:The naming mechanism for accessing resources.The host name of the resource to be stored.The name of the resource itself, represented by the path.Uri represents the data to be operated, and Uri mainly contains two parts of information: 1. , the ContentProvider that needs to be operated, and 2. what is the data in the Contentprovider. A Uri consists of the following parts:The 1. scheme:ContentProvider of the content provider (scheme) has been defined by Android as: content://.2. host name (or Authority): used to uniquely identify the ContentProvider, and the external caller can find it based on the identity.3. path (path) : can be used to indicate the data we want to operate, the path should be built according to the business, as follows:To operate a record of ID 10 in the contact table, you can build this path: /contact/10To operate the name field of the record ID of 10 in the contact table, contact/10/nameTo operate all the records in the contact table, you can build this path: /contactThe data to be operated does not necessarily come from the database or the file, but he stores it as follows:To operate the name node under the contact node in the XML file, you can build this path: /contact/nameIf you want to convert a string to Uri, you can use the parse ()method in the Uri class as follows:Uri URI = Uri. parse("content://com・ changcheng. provider, contactprovider/contact 〃)Consider the following URI, which represents the current HTML 4 specification:Http://www・ webmonkey, com. cn/html/html40/The URI is like this: This is a resource that can be accessed through the HTTP protocol, located in the mainOn machine ^vw. webmonkey, com. cn, access via path ,,/html/html40/,. In the HTML documentOther resources include 〃mailto〃 (send and receive email) and 〃Ftp〃 (FTP access).This is another example of URI, pointing to a users mailbox:mailto: joe@someplace. com/z, 〃〉Joe Cool〈/A>〃Note: most readers may be familiar with 〃URL〃 instead of 〃URI〃・ URL is a subset of the URI naming mechanism.Fragment identifierSome URI point to the interior of a resource. The URI 〃#〃 end, and with a anchor logoCharacters (called fragment identifiers). For example, here is a URI that points to section 2:Http://somesite. com/html/top. htmttsection 2Relative URI does not contain any naming specification information. Its path usually refers to the resources on the same machine. Relative UR I may contain relative paths, such as 〃.・.〃 that represent the upper layer path) and may contain fragment TagsSymbol.To illustrate the relative URI, suppose we have a basic URI http://www. acme, com/support/intro, htmThe relative URI is used in the following link:SuppliersIt expands into full URI, that is, 〃http://www・ acme, com/support/suppliers. htm〃〃,The following is the relative URI of an image:It expands into full URI, that is, 〃http://www・ acme, com/icons/logo. gif〃〃・In HTML, URI is used:Link to another document or resource (see A and LINK elements).Link to an external style sheet or script (see LINK and SCRIPT elements).Include images, objects, or applet in the page (see I MAG, OBJECT, APPLET, and INPUT)Element).Create image mappings (see MAP and AREA elements).Submit a form (see FORM).Create a framework document (see FRAME and IFRAME elements).Refer to an external reference (see Q, BLOCKQUOTE, INS, and DEL elements).Point to the metadata for a description document (see the HEAD element).2. what is URL?:URL is the abbreviation of Uniform ResourceLocation, which is used as the uniform resource locator”. Popularly speaking, URL is a string used to describe information resources on Internet, mainly used in various WWW client programs and server programs, especially the famous Mosaic. URL can be used in a unified format to describe all kinds of information resources, including files, servers, addresses and directories.URL formatThe format of URL consists of the following three parts:The first part is agreement (or service);The second part is the host IP address that contains the resource (sometimes including port numbers);The third part is the specific address of the host resource. Such as directories and filenames.Between the first part and the second part 〃: / / symbols separated from the second part and the third part" / "sign off. The first and second parts are indispensable, and the third part can sometimes be omitted.URL exampleFile URL:When a file is represented in URL, the server is represented in file, followed 。
