最早在Android方面接触这两个概念,是学习ContentProvider的时候,当时花了很多时间,始终不能很好的理解他们的区别,顺带着ContentProvider的用法也无法理解,最近通过实现网页链接和Android-APP的无缝跳转问题,对这里的区别有了一定的认识。
下面是来自StackOverFlow上的一段解释What's the difference between a URI and a URL?:
A URI can be further classified as a locator, a name, or both. The term "Uniform Resource Locator" (URL) refers to the subset of URIs that, in addition to identifying a resource, provide a means of locating the resource by describing its primary access mechanism (e.g., its network "location"). The term "Uniform Resource Name" (URN) has been used historically to refer to both URIs under the "urn" scheme [RFC2141], which are required to remain globally unique and persistent even when the resource ceases to exist or becomes unavailable, and to any other URI with the properties of a name.
URI(Uniform Resource Identifier)中文名为统一资源标识符。
URL(Uniform Resource Locator)中文名字为统一资源定位符。
Examples
- Roger Pate
This is my name, which is identification. It is like a URI, but cannot be a URL, as it tells you nothing about my location or how to contact me. In this case it also happens to identify at least 5 other people in the USA alone.
- 4914 West Bay Street, Nassau, Bahamas
This is a location, which is identification for that physical location. It is like both a URL and URI (since all URLs are URIs), and also identifies me indirectly as "resident of..". In this case it uniquely identifies me, but that would change if I get a roommate.
I say "like" because these examples do not follow the required syntax.
URIs identify and URLs locate; however, locations are also identifications, so every URL is also a URI, but there are URIs which are not URLs.
在Wikipedia上面,解释如下:
URIs can be classified as locators (URLs), as names (URNs), or as both. A uniform resource name (URN) functions like a person's name, while a uniform resource locator (URL) resembles that person's street address. In other words: the URN defines an item's identity, while the URL provides a method for finding it.
A uniform resource locator, abbreviated URL, also known as web address, is a specific character string that constitutes a reference to a resource. In most web browsers, the URL of a web page is displayed on top inside an address bar. An example of a typical URL would be "http://en.example.org/wiki/Main_Page".
三者的关系如下:
OK,上面一大段英文之后,如果看懂了,基本上有了一个大概的了解,URN确定了一个资源的身份,比如,我可以叫你为大脚印,大脚印标志了你的身份,但是我应该如何找到你呢?XX学校XX班级的大脚印!这是一个URL(但是其实根据上面URL的定义,URL定义的应该是网址,我的理解是,URL代表着URI的一种形式,URI中用来标志一个资源位置的方式还有很多,最常见的比如文件系统中的某个文件的绝对地址),通过这个URL我们可以找到这个资源!URL和URN同统一包含于URI。
下面我去整理一下ContentProvider的有关文章。