转载请表明出处:http://blog.csdn.net/u012637501(嵌入式_小J的天空)
一、UriMatcher与ContentUris工具类
URI( String
spec)
Creates a new URI instance by parsing
spec .
|
URI( String
scheme,
String
schemeSpecificPart,
String
fragment)
Creates a new URI instance of the given unencoded component parts.
|
URI( String
scheme,
String
userInfo,
String
host, int port,
String
path,
String
query,
String
fragment)
Creates a new URI instance of the given unencoded component parts.
|
URI( String
scheme,
String
host,
String
path,
String
fragment)
Creates a new URI instance of the given unencoded component parts.
|
URI( String
scheme,
String
authority,
String
path,
String
query,
String
fragment)
Creates a new URI instance of the given unencoded component parts.
|
Component | Example value | Also known as |
---|---|---|
Scheme(方案/协议) |
http |
protocol |
Scheme-specific part |
//username:password@host:8080/directory/file?query#fragment |
|
Authority(身份认证) |
username:password@host:8080 |
|
User Info(用户信息) |
username:password |
|
Host(主机) |
host |
|
Port(串口) |
8080 |
|
Path(资源路径) |
/directory/file |
|
Query |
query |
|
Fragment(资源名称) |
fragment |
ref |
absolute or relative
.
http://android.com/robots.txt
robots.txt
URI absolute = new URI("http://android.com/");
URI relative = new URI("robots.txt");
URI resolved = new URI("http://android.com/robots.txt");
// print "http://android.com/robots.txt"
System.out.println(absolute.resolve(relative));
// print "robots.txt"
System.out.println(absolute.relativize(resolved));
(4)
Opaque vs. Hierarchical URIs
opaque or hierarchical
. Relative URIs are always hierarchical.
http://android.com/robots.txt
mailto:[email protected]
Component | Example value |
---|---|
Scheme | mailto |
Scheme-specific part(不是斜杠'/'开头) | [email protected] |
Fragment |
Component | Legal Characters(合法字符) | Other Constraints (其他限制条件) |
Raw Value(原始值) | Value(解码得到的值) |
---|---|---|---|---|
Scheme | 0-9 , a-z , A-Z , +-. |
First character must be ina-z , A-Z |
|
http |
Scheme-specific part | 0-9 , a-z , A-Z , _-!.~'()*,;:$&+=?/[]@ |
Non-ASCII characters okay
(非ASCII字符即可)
|
//user:pa55w%3Frd@host:80/doc%7Csearch?q=green%20robots |
//user:pa55w?rd@host:80/doc|search?q=green robots |
Authority | 0-9 , a-z , A-Z , _-!.~'()*,;:$&+=@[] |
Non-ASCII characters okay | user:pa55w%3Frd@host:80 |
user:pa55w?rd@host:80 |
User Info | 0-9 , a-z , A-Z , _-!.~'()*,;:$&+= |
Non-ASCII characters okay | user:pa55w%3Frd |
user:pa55w?rd |
Host | 0-9 , a-z , A-Z , -.[] |
Domain name, IPv4 address or [IPv6 address] |
|
host |
Port | 0-9 |
|
|
80 |
Path | 0-9 , a-z , A-Z , _-!.~'()*,;:$&+ =/@ |
Non-ASCII characters okay | /doc%7Csearch |
/doc|search |
Query | 0-9 , a-z , A-Z , _-!.~'()*,;:$&+=?/[]@ |
Non-ASCII characters okay | q=green%20robots |
q=green robots |
Fragment | 0-9 , a-z , A-Z , _-!.~'()*,;:$&+=?/[]@ |
Non-ASCII characters okay | over%206%22 |
over 6" |
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
class
|
Uri.Builder | Helper class for building or manipulating URI references. |