| java.lang.Object | ||
| android.net.Uri | Parcelable Comparable | |
This class allows you to create, decode, parse, and examine immutable URI reference objects that conform to RFC 2396. The class also includes public utility methods for encoding and decoding Strings. All encoding is done in UTF-8, with special characters encoded in '%'-escaped hexadecimal values (all characters other than alphanumeric or '.' (dot), '-' (hyphen), '*' (star), and '_' (underscore) characters). Spaces are also substituted by '+'. To encode with charset other than UTF-8, see URLEncoder.
In the interest of performance, this class performs little to no validation. Behavior is undefined for invalid input. This class is very forgiving -- in the face of invalid input, it will return garbage rather than throw an exception unless otherwise specified.
Nested Classes| Uri.Builder | Helper class for building or manipulating URI references. |
| Value | ||||
|---|---|---|---|---|
| Creator | CREATOR | Reads Uris from Parcels. | ||
| Uri | EMPTY | The empty URI, equivalent to "". |
| abstract | Builder | buildUpon() | |||
| Constructs a new builder, copying the attributes from this Uri. | |||||
| int | compareTo(Uri other) | ||||
| Compares the string representation of this Uri with that of other. | |||||
| static | String | decode(String s) | |||
| Decodes '%'-escaped octets in the given string using the UTF-8 scheme. | |||||
| static | String | encode(String s) | |||
| Encodes characters in the given string as '%'-escaped octets using the UTF-8 scheme. | |||||
| static | String | encode(String s, String allow) | |||
| Encodes characters in the given string as '%'-escaped octets using the UTF-8 scheme, except those that are given in allow. | |||||
| boolean | equals(Object o) | ||||
| Compares this Uri to another object for equality. | |||||
| static | Uri | fromFile(File file) | |||
| Creates a Uri from a File. | |||||
| static | Uri | fromParts(String scheme, String ssp, String fragment) | |||
| Creates an opaque Uri from the given components. | |||||
| abstract | String | getAuthority() | |||
| Gets the decoded authority component of this URI. | |||||
| abstract | String | getEncodedAuthority() | |||
| Gets the encoded authority component of this URI. | |||||
| abstract | String | getEncodedFragment() | |||
| Gets the encoded fragment part of this URI, everything after the '#'. | |||||
| abstract | String | getEncodedPath() | |||
| Gets the encoded path component of this URI. | |||||
| abstract | String | getEncodedQuery() | |||
| Gets the encoded query component of this URI. | |||||
| abstract | String | getEncodedSchemeSpecificPart() | |||
| Gets the encoded scheme-specific part of this URI. | |||||
| abstract | String | getEncodedUserInfo() | |||
| Gets the encoded user information from the authority component. | |||||
| abstract | String | getFragment() | |||
| Gets the decoded fragment part of this URI, everything after the '#'. | |||||
| abstract | String | getHost() | |||
| Gets the encoded host from the authority component of this URI. | |||||
| abstract | String | getLastPathSegment() | |||
| Gets the decoded last segment path of this URI. | |||||
| abstract | String | getPath() | |||
| Gets the decoded path component of this URI. | |||||
| abstract | List | getPathSegments() | |||
| Gets each of the decoded path segments of this URI. | |||||
| abstract | int | getPort() | |||
| Gets the port number from the authority component of this URI. | |||||
| abstract | String | getQuery() | |||
| Gets the decoded query component of this URI. | |||||
| String | getQueryParameter(String key) | ||||
| Searches the query string for the first value with the given key. | |||||
| List | getQueryParameters(String key) | ||||
| Searches the query string for parameter values with the given key. | |||||
| abstract | String | getScheme() | |||
| Gets the scheme of this URI, such as "http". | |||||
| abstract | String | getSchemeSpecificPart() | |||
| Gets the decoded scheme-specific part of this URI. | |||||
| abstract | String | getUserInfo() | |||
| Gets the decoded user information from the authority component. | |||||
| int | hashCode() | ||||
| Hashes the encoded string represention of this Uri consistently with equals(Object). | |||||
| boolean | isAbsolute() | ||||
| Returns true if this URI is absolute. | |||||
| abstract | boolean | isHierarchical() | |||
| Returns true if this URI is hierarchical like "http://google.com". | |||||
| boolean | isOpaque() | ||||
| Returns true if this URI is opaque like "mailto:nobody@google.com". | |||||
| abstract | boolean | isRelative() | |||
| Returns true if this URI is relative. | |||||
| static | Uri | parse(String uriString) | |||
| Creates a Uri object from the given encoded URI string. | |||||
| abstract | String | toString() | |||
| Returns the encoded string representation of this Uri. | |||||
| static | Uri | withAppendedPath(Uri baseUri, String pathSegment) | |||
| Creates a new Uri by encoding and appending a path segment to a base Uri. | |||||
| static | void | writeToParcel(Parcel out, Uri uri) | |||
| Writes a Uri to a Parcel. | |||||
Methods inherited
from class
java.lang.Object
Methods inherited
from interface
java.lang.Comparable
Methods inherited
from interface
android.os.Parcelable
| other | a Uri object to be compared to this one, on the basis of the String values. |
|---|
| s | encoded string to decode |
|---|
| s | string to encode |
|---|
| s | string to encode |
|---|---|
| allow | set of additional characters to allow in the encoded form, null if no characters should be skipped |
| o | object to compare to this Uri, which must be an instance of a Uri object. |
|---|
Example: "file:///tmp/android.txt"
| NullPointerException | if file is null |
|---|
| scheme | of the URI |
|---|---|
| ssp | scheme-specific-part, everything between the scheme separator (':') and the fragment separator ('#'), which will get encoded |
| fragment | fragment, everything after the '#', null if undefined, will get encoded |
| NullPointerException | if scheme or ssp is null |
|---|
[ userinfo '@' ] host [ ':' port ]
Examples: "google.com", "nobody@google.com:80"
Any '%'-escaped octets are decoded. Invalid octets are replaced with the unicode replacement character ("\\uFFFD").
[ userinfo '@' ] host [ ':' port ]
Examples: "google.com", "nobody@google.com:80"
Any '%'-escaped octets are intact.
Any '%'-escaped octets are intact.
Any '%'-escaped octets are intact.
Any '%'-escaped octets are intact.
Example: "//www.google.com/search?q=android"
Any '%'-escaped octets are intact.
Any '%'-escaped octets are intact.
Any '%'-escaped octets are decoded. Invalid octets are replaced with the unicode replacement character ("\\uFFFD").
Any '%'-escaped octets are intact.
Any '%'-escaped octets are decoded. Invalid octets are replaced with the unicode replacement character ("\\uFFFD").
Any '%'-escaped octets are decoded. Invalid octets are replaced with the unicode replacement character ("\\uFFFD").
Any '%'-escaped octets are decoded. Invalid octets are replaced with the unicode replacement character ("\\uFFFD").
Any '%'-escaped octets are decoded. Invalid octets are replaced with the unicode replacement character ("\\uFFFD").
| key | which will be encoded |
|---|
| UnsupportedOperationException | if this isn't a hierarchical URI |
|---|---|
| NullPointerException | if key is null |
| key | which will be encoded |
|---|
| UnsupportedOperationException | if this isn't a hierarchical URI |
|---|---|
| NullPointerException | if key is null |
Example: "//www.google.com/search?q=android"
Any '%'-escaped octets are decoded. Invalid octets are replaced with the unicode replacement character ("\\uFFFD").
Any '%'-escaped octets are decoded. Invalid octets are replaced with the unicode replacement character ("\\uFFFD").
| uriString | an RFC 3296-compliant, encoded URI |
|---|
| NullPointerException | if uriString is null |
|---|
Any '%'-escaped octets are intact.
| baseUri | Uri to append path segment to |
|---|---|
| pathSegment | to encode and append |