Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Nested Classes](https://developer.android.com/reference/android/net/Uri#nestedclasses) \| [Inherited Constants](https://developer.android.com/reference/android/net/Uri#inhconstants) \| [Fields](https://developer.android.com/reference/android/net/Uri#lfields) \| [Methods](https://developer.android.com/reference/android/net/Uri#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/net/Uri#inhmethods)

# Uri

*** ** * ** ***

` public abstract class Uri `   
` extends https://developer.android.com/reference/java/lang/Object ` ` implements https://developer.android.com/reference/java/lang/Comparable<https://developer.android.com/reference/android/net/Uri>, https://developer.android.com/reference/android/os/Parcelable `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.net.Uri |

<br />

*** ** * ** ***

Immutable URI reference. A URI reference includes a URI and a fragment, the component of the URI following a '#'. Builds and parses URI references which conform to [RFC 2396](http://www.faqs.org/rfcs/rfc2396.html).

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.

## Summary

| ### Nested classes ||
|---|---|
| ` class` | `https://developer.android.com/reference/android/net/Uri.Builder` Helper class for building or manipulating URI references. |

### Inherited constants

From interface `https://developer.android.com/reference/android/os/Parcelable` `int` `https://developer.android.com/reference/android/os/Parcelable#CONTENTS_FILE_DESCRIPTOR`

Descriptor bit used with `https://developer.android.com/reference/android/os/Parcelable#describeContents()`: indicates that the Parcelable object's flattened representation includes a file descriptor.
`int` `https://developer.android.com/reference/android/os/Parcelable#PARCELABLE_WRITE_RETURN_VALUE`

Flag for use with `https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)`: the object being written is a return value, that is the result of a function such as "`Parcelable someFunction()`", "`void someFunction(out Parcelable)`", or "`void someFunction(inout Parcelable)`".

| ### Fields ||
|---|---|
| ` public static final https://developer.android.com/reference/android/os/Parcelable.Creator<https://developer.android.com/reference/android/net/Uri>` | `https://developer.android.com/reference/android/net/Uri#CREATOR` Reads Uris from Parcels. |
| ` public static final https://developer.android.com/reference/android/net/Uri` | `https://developer.android.com/reference/android/net/Uri#EMPTY` The empty URI, equivalent to "". |

| ### Public methods ||
|---|---|
| ` abstract https://developer.android.com/reference/android/net/Uri.Builder` | ` https://developer.android.com/reference/android/net/Uri#buildUpon()() ` Constructs a new builder, copying the attributes from this Uri. |
| ` int` | ` https://developer.android.com/reference/android/net/Uri#compareTo(android.net.Uri)(https://developer.android.com/reference/android/net/Uri other) ` Compares the string representation of this Uri with that of another. |
| ` static https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/Uri#decode(java.lang.String)(https://developer.android.com/reference/java/lang/String s) ` Decodes '%'-escaped octets in the given string using the UTF-8 scheme. |
| ` static https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/Uri#encode(java.lang.String,%20java.lang.String)(https://developer.android.com/reference/java/lang/String s, https://developer.android.com/reference/java/lang/String allow) ` Encodes characters in the given string as '%'-escaped octets using the UTF-8 scheme. |
| ` static https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/Uri#encode(java.lang.String)(https://developer.android.com/reference/java/lang/String s) ` Encodes characters in the given string as '%'-escaped octets using the UTF-8 scheme. |
| ` boolean` | ` https://developer.android.com/reference/android/net/Uri#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object o) ` Compares this Uri to another object for equality. |
| ` static https://developer.android.com/reference/android/net/Uri` | ` https://developer.android.com/reference/android/net/Uri#fromFile(java.io.File)(https://developer.android.com/reference/java/io/File file) ` Creates a Uri from a file. |
| ` static https://developer.android.com/reference/android/net/Uri` | ` https://developer.android.com/reference/android/net/Uri#fromParts(java.lang.String,%20java.lang.String,%20java.lang.String)(https://developer.android.com/reference/java/lang/String scheme, https://developer.android.com/reference/java/lang/String ssp, https://developer.android.com/reference/java/lang/String fragment) ` Creates an opaque Uri from the given components. |
| ` abstract https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/Uri#getAuthority()() ` Gets the decoded authority part of this URI. |
| ` boolean` | ` https://developer.android.com/reference/android/net/Uri#getBooleanQueryParameter(java.lang.String,%20boolean)(https://developer.android.com/reference/java/lang/String key, boolean defaultValue) ` Searches the query string for the first value with the given key and interprets it as a boolean value. |
| ` abstract https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/Uri#getEncodedAuthority()() ` Gets the encoded authority part of this URI. |
| ` abstract https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/Uri#getEncodedFragment()() ` Gets the encoded fragment part of this URI, everything after the '#'. |
| ` abstract https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/Uri#getEncodedPath()() ` Gets the encoded path. |
| ` abstract https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/Uri#getEncodedQuery()() ` Gets the encoded query component from this URI. |
| ` abstract https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/Uri#getEncodedSchemeSpecificPart()() ` Gets the scheme-specific part of this URI, i.e. everything between the scheme separator ':' and the fragment separator '#'. |
| ` abstract https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/Uri#getEncodedUserInfo()() ` Gets the encoded user information from the authority. |
| ` abstract https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/Uri#getFragment()() ` Gets the decoded fragment part of this URI, everything after the '#'. |
| ` abstract https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/Uri#getHost()() ` Gets the encoded host from the authority for this URI. |
| ` abstract https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/Uri#getLastPathSegment()() ` Gets the decoded last segment in the path. |
| ` abstract https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/Uri#getPath()() ` Gets the decoded path. |
| ` abstract https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/java/lang/String>` | ` https://developer.android.com/reference/android/net/Uri#getPathSegments()() ` Gets the decoded path segments. |
| ` abstract int` | ` https://developer.android.com/reference/android/net/Uri#getPort()() ` Gets the port from the authority for this URI. |
| ` abstract https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/Uri#getQuery()() ` Gets the decoded query component from this URI. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/Uri#getQueryParameter(java.lang.String)(https://developer.android.com/reference/java/lang/String key) ` Searches the query string for the first value with the given key. |
| ` https://developer.android.com/reference/java/util/Set<https://developer.android.com/reference/java/lang/String>` | ` https://developer.android.com/reference/android/net/Uri#getQueryParameterNames()() ` Returns a set of the unique names of all query parameters. |
| ` https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/java/lang/String>` | ` https://developer.android.com/reference/android/net/Uri#getQueryParameters(java.lang.String)(https://developer.android.com/reference/java/lang/String key) ` Searches the query string for parameter values with the given key. |
| ` abstract https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/Uri#getScheme()() ` Gets the scheme of this URI. |
| ` abstract https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/Uri#getSchemeSpecificPart()() ` Gets the scheme-specific part of this URI, i.e. everything between the scheme separator ':' and the fragment separator '#'. |
| ` abstract https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/Uri#getUserInfo()() ` Gets the decoded user information from the authority. |
| ` int` | ` https://developer.android.com/reference/android/net/Uri#hashCode()() ` Hashes the encoded string represention of this Uri consistently with `https://developer.android.com/reference/android/net/Uri#equals(java.lang.Object)`. |
| ` boolean` | ` https://developer.android.com/reference/android/net/Uri#isAbsolute()() ` Returns true if this URI is absolute, i.e. if it contains an explicit scheme. |
| ` abstract boolean` | ` https://developer.android.com/reference/android/net/Uri#isHierarchical()() ` Returns true if this URI is hierarchical like "http://google.com". |
| ` boolean` | ` https://developer.android.com/reference/android/net/Uri#isOpaque()() ` Returns true if this URI is opaque like "mailto:nobody@google.com". |
| ` abstract boolean` | ` https://developer.android.com/reference/android/net/Uri#isRelative()() ` Returns true if this URI is relative, i.e. if it doesn't contain an explicit scheme. |
| ` https://developer.android.com/reference/android/net/Uri` | ` https://developer.android.com/reference/android/net/Uri#normalizeScheme()() ` Return an equivalent URI with a lowercase scheme component. |
| ` static https://developer.android.com/reference/android/net/Uri` | ` https://developer.android.com/reference/android/net/Uri#parse(java.lang.String)(https://developer.android.com/reference/java/lang/String uriString) ` Creates a Uri which parses the given encoded URI string. |
| ` abstract https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/net/Uri#toString()() ` Returns the encoded string representation of this URI. |
| ` static https://developer.android.com/reference/android/net/Uri` | ` https://developer.android.com/reference/android/net/Uri#withAppendedPath(android.net.Uri,%20java.lang.String)(https://developer.android.com/reference/android/net/Uri baseUri, https://developer.android.com/reference/java/lang/String pathSegment) ` Creates a new Uri by appending an already-encoded path segment to a base Uri. |
| ` static void` | ` https://developer.android.com/reference/android/net/Uri#writeToParcel(android.os.Parcel,%20android.net.Uri)(https://developer.android.com/reference/android/os/Parcel out, https://developer.android.com/reference/android/net/Uri uri) ` Writes a Uri to a Parcel. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.
From interface ` https://developer.android.com/reference/java/lang/Comparable ` ` abstract int` ` https://developer.android.com/reference/java/lang/Comparable#compareTo(T)(https://developer.android.com/reference/android/net/Uri o) `

Compares this object with the specified object for order.
From interface ` https://developer.android.com/reference/android/os/Parcelable ` ` abstract int` ` https://developer.android.com/reference/android/os/Parcelable#describeContents()() `

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.
` abstract void` ` https://developer.android.com/reference/android/os/Parcelable#writeToParcel(android.os.Parcel,%20int)(https://developer.android.com/reference/android/os/Parcel dest, int flags) `

Flatten this object in to a Parcel.

## Fields

### CREATOR

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final Creator<Uri> CREATOR
```

Reads Uris from Parcels.

<br />

### EMPTY

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final Uri EMPTY
```

The empty URI, equivalent to "".

<br />

## Public methods

### buildUpon

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract Uri.Builder buildUpon ()
```

Constructs a new builder, copying the attributes from this Uri.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Uri.Builder` | <br /> |

### compareTo

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int compareTo (Uri other)
```

Compares the string representation of this Uri with that of another.

<br />

| Parameters ||
|---|---|
| `other` | `Uri` <br /> |

| Returns ||
|---|---|
| `int` | <br /> |

### decode

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static String decode (String s)
```

Decodes '%'-escaped octets in the given string using the UTF-8 scheme. Replaces invalid octets with the unicode replacement character ("\\\\uFFFD").

<br />

| Parameters ||
|---|---|
| `s` | `String`: encoded string to decode <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the given string with escaped octets decoded, or null if s is null <br /> |

### encode

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static String encode (String s, 
                String allow)
```

Encodes characters in the given string as '%'-escaped octets using the UTF-8 scheme. Leaves letters ("A-Z", "a-z"), numbers ("0-9"), and unreserved characters ("_-!.\~'()\*") intact. Encodes all other characters with the exception of those specified in the allow argument.

<br />

| Parameters ||
|---|---|
| `s` | `String`: string to encode <br /> |
| `allow` | `String`: set of additional characters to allow in the encoded form, null if no characters should be skipped <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | an encoded version of s suitable for use as a URI component, or null if s is null <br /> |

### encode

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static String encode (String s)
```

Encodes characters in the given string as '%'-escaped octets using the UTF-8 scheme. Leaves letters ("A-Z", "a-z"), numbers ("0-9"), and unreserved characters ("_-!.\~'()\*") intact. Encodes all other characters.

<br />

| Parameters ||
|---|---|
| `s` | `String`: string to encode <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | an encoded version of s suitable for use as a URI component, or null if s is null <br /> |

### equals

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean equals (Object o)
```

Compares this Uri to another object for equality. Returns true if the encoded string representations of this Uri and the given Uri are equal. Case counts. Paths are not normalized. If one Uri specifies a default port explicitly and the other leaves it implicit, they will not be considered equal.

<br />

| Parameters ||
|---|---|
| `o` | `Object`: This value may be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | `true` if this object is the same as the obj argument; `false` otherwise. <br /> |

### fromFile

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Uri fromFile (File file)
```

Creates a Uri from a file. The URI has the form "file:// ". Encodes path characters with the exception of '/'.

Example: "file:///tmp/android.txt"

<br />

| Parameters ||
|---|---|
| `file` | `File` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Uri` | a Uri for the given file <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if file is null |

### fromParts

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Uri fromParts (String scheme, 
                String ssp, 
                String fragment)
```

Creates an opaque Uri from the given components. Encodes the ssp which means this method cannot be used to create hierarchical URIs.

<br />

| Parameters ||
|---|---|
| `scheme` | `String`: of the URI <br /> |
| `ssp` | `String`: scheme-specific-part, everything between the scheme separator (':') and the fragment separator ('#'), which will get encoded <br /> |
| `fragment` | `String`: fragment, everything after the '#', null if undefined, will get encoded <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Uri` | Uri composed of the given scheme, ssp, and fragment <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if scheme or ssp is null |

**See also:**

- `https://developer.android.com/reference/android/net/Uri.Builder`

### getAuthority

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract String getAuthority ()
```

Gets the decoded authority part of this URI. For server addresses, the authority is structured as follows: `[ userinfo '@' ] host [ ':' port ]`

Examples: "google.com", "bob@google.com:80"

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the authority for this URI or null if not present <br /> |

### getBooleanQueryParameter

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean getBooleanQueryParameter (String key, 
                boolean defaultValue)
```

Searches the query string for the first value with the given key and interprets it as a boolean value. "false" and "0" are interpreted as `false`, everything else is interpreted as `true`.

<br />

| Parameters ||
|---|---|
| `key` | `String`: which will be decoded <br /> |
| `defaultValue` | `boolean`: the default value to return if there is no query parameter for key <br /> |

| Returns ||
|---|---|
| `boolean` | the boolean interpretation of the query parameter key <br /> |

### getEncodedAuthority

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract String getEncodedAuthority ()
```

Gets the encoded authority part of this URI. For server addresses, the authority is structured as follows: `[ userinfo '@' ] host [ ':' port ]`

Examples: "google.com", "bob@google.com:80"

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the authority for this URI or null if not present <br /> |

### getEncodedFragment

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract String getEncodedFragment ()
```

Gets the encoded fragment part of this URI, everything after the '#'.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the encoded fragment or null if there isn't one <br /> |

### getEncodedPath

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract String getEncodedPath ()
```

Gets the encoded path.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the encoded path, or null if this is not a hierarchical URI (like "mailto:nobody@google.com") or the URI is invalid <br /> |

### getEncodedQuery

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract String getEncodedQuery ()
```

Gets the encoded query component from this URI. The query comes after the query separator ('?') and before the fragment separator ('#'). This method would return "q=android" for "http://www.google.com/search?q=android".

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the encoded query or null if there isn't one <br /> |

### getEncodedSchemeSpecificPart

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract String getEncodedSchemeSpecificPart ()
```

Gets the scheme-specific part of this URI, i.e. everything between the scheme separator ':' and the fragment separator '#'. If this is a relative URI, this method returns the entire URI. Leaves escaped octets intact.

Example: "//www.google.com/search?q=android"

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the encoded scheme-specific-part <br /> |

### getEncodedUserInfo

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract String getEncodedUserInfo ()
```

Gets the encoded user information from the authority. For example, if the authority is "nobody@google.com", this method will return "nobody".

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the user info for this URI or null if not present <br /> |

### getFragment

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract String getFragment ()
```

Gets the decoded fragment part of this URI, everything after the '#'.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the decoded fragment or null if there isn't one <br /> |

### getHost

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract String getHost ()
```

Gets the encoded host from the authority for this URI. For example, if the authority is "bob@google.com", this method will return "google.com".

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the host for this URI or null if not present <br /> |

### getLastPathSegment

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract String getLastPathSegment ()
```

Gets the decoded last segment in the path.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the decoded last segment or null if the path is empty <br /> |

### getPath

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract String getPath ()
```

Gets the decoded path.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the decoded path, or null if this is not a hierarchical URI (like "mailto:nobody@google.com") or the URI is invalid <br /> |

### getPathSegments

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract List<String> getPathSegments ()
```

Gets the decoded path segments.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/java/lang/String>` | decoded path segments, each without a leading or trailing '/' <br /> |

### getPort

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract int getPort ()
```

Gets the port from the authority for this URI. For example, if the authority is "google.com:80", this method will return 80.

<br />

| Returns ||
|---|---|
| `int` | the port for this URI or -1 if invalid or not present <br /> |

### getQuery

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract String getQuery ()
```

Gets the decoded query component from this URI. The query comes after the query separator ('?') and before the fragment separator ('#'). This method would return "q=android" for "http://www.google.com/search?q=android".

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the decoded query or null if there isn't one <br /> |

### getQueryParameter

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String getQueryParameter (String key)
```

Searches the query string for the first value with the given key.

**Warning:** Prior to Jelly Bean, this decoded the '+' character as '+' rather than ' '.

<br />

| Parameters ||
|---|---|
| `key` | `String`: which will be encoded <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the decoded value or null if no parameter is found <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if key is null |
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException` | if this isn't a hierarchical URI |

### getQueryParameterNames

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Set<String> getQueryParameterNames ()
```

Returns a set of the unique names of all query parameters. Iterating over the set will return the names in order of their first occurrence.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/Set<https://developer.android.com/reference/java/lang/String>` | a set of decoded names <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException` | if this isn't a hierarchical URI |

### getQueryParameters

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public List<String> getQueryParameters (String key)
```

Searches the query string for parameter values with the given key.

<br />

| Parameters ||
|---|---|
| `key` | `String`: which will be encoded <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/java/lang/String>` | a list of decoded values <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if key is null |
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException` | if this isn't a hierarchical URI |

### getScheme

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract String getScheme ()
```

Gets the scheme of this URI. Example: "http"

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the scheme or null if this is a relative URI <br /> |

### getSchemeSpecificPart

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract String getSchemeSpecificPart ()
```

Gets the scheme-specific part of this URI, i.e. everything between the scheme separator ':' and the fragment separator '#'. If this is a relative URI, this method returns the entire URI. Decodes escaped octets.

Example: "//www.google.com/search?q=android"

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the decoded scheme-specific-part <br /> |

### getUserInfo

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract String getUserInfo ()
```

Gets the decoded user information from the authority. For example, if the authority is "nobody@google.com", this method will return "nobody".

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the user info for this URI or null if not present <br /> |

### hashCode

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int hashCode ()
```

Hashes the encoded string represention of this Uri consistently with `https://developer.android.com/reference/android/net/Uri#equals(java.lang.Object)`.

<br />

| Returns ||
|---|---|
| `int` | a hash code value for this object. <br /> |

### isAbsolute

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isAbsolute ()
```

Returns true if this URI is absolute, i.e. if it contains an explicit scheme.

<br />

| Returns ||
|---|---|
| `boolean` | true if this URI is absolute, false if it's relative <br /> |

### isHierarchical

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract boolean isHierarchical ()
```

Returns true if this URI is hierarchical like "http://google.com". Absolute URIs are hierarchical if the scheme-specific part starts with a '/'. Relative URIs are always hierarchical.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### isOpaque

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean isOpaque ()
```

Returns true if this URI is opaque like "mailto:nobody@google.com". The scheme-specific part of an opaque URI cannot start with a '/'.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### isRelative

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract boolean isRelative ()
```

Returns true if this URI is relative, i.e. if it doesn't contain an explicit scheme.

<br />

| Returns ||
|---|---|
| `boolean` | true if this URI is relative, false if it's absolute <br /> |

### normalizeScheme

Added in [API level 16](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Uri normalizeScheme ()
```

Return an equivalent URI with a lowercase scheme component. This aligns the Uri with Android best practices for intent filtering.

For example, "HTTP://www.android.com" becomes "http://www.android.com"

All URIs received from outside Android (such as user input, or external sources like Bluetooth, NFC, or the Internet) should be normalized before they are used to create an Intent.

This method does *not* validate bad URIs, or 'fix' poorly formatted URIs - so do not use it for input validation. A Uri will always be returned, even if the Uri is badly formatted to begin with and a scheme component cannot be found.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Uri` | normalized Uri (never null) <br /> |

**See also:**

- `https://developer.android.com/reference/android/content/Intent#setData(android.net.Uri)`
- `https://developer.android.com/reference/android/content/Intent#setDataAndNormalize(android.net.Uri)`

### parse

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Uri parse (String uriString)
```

Creates a Uri which parses the given encoded URI string.

<br />

| Parameters ||
|---|---|
| `uriString` | `String`: an RFC 2396-compliant, encoded URI <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Uri` | Uri for this given uri string <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if uriString is null |

### toString

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract String toString ()
```

Returns the encoded string representation of this URI. Example: "http://google.com/"

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | a string representation of the object. <br /> |

### withAppendedPath

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Uri withAppendedPath (Uri baseUri, 
                String pathSegment)
```

Creates a new Uri by appending an already-encoded path segment to a base Uri.

<br />

| Parameters ||
|---|---|
| `baseUri` | `Uri`: Uri to append path segment to <br /> |
| `pathSegment` | `String`: encoded path segment to append <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Uri` | a new Uri based on baseUri with the given segment appended to the path <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if baseUri is null |

### writeToParcel

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void writeToParcel (Parcel out, 
                Uri uri)
```

Writes a Uri to a Parcel.

<br />

| Parameters ||
|---|---|
| `out` | `Parcel`: parcel to write to <br /> |
| `uri` | `Uri`: to write, can be null <br /> |