Uri

abstract class Uri : Comparable<Uri>

Types

Link copied to clipboard
class Builder

Helper class for building or manipulating URI references. Not safe for concurrent use.

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
abstract fun buildUpon(): Uri.Builder

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

Link copied to clipboard
open operator override fun compareTo(other: Uri): Int
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean

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.

Link copied to clipboard
fun getBooleanQueryParameter(key: String, defaultValue: Boolean): Boolean

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.

Link copied to clipboard
fun getQueryParameter(key: String): String?

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

Link copied to clipboard
fun getQueryParameterNames(): Set<String>

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.

Link copied to clipboard
fun getQueryParameters(key: String): List<String>

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

Link copied to clipboard
open override fun hashCode(): Int

Hashes the encoded string represention of this Uri consistently with .equals.

Link copied to clipboard
fun normalizeScheme(): Uri

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

Link copied to clipboard
abstract override fun toString(): String

Properties

Link copied to clipboard
abstract val authority: String?

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

Link copied to clipboard
abstract val encodedAuthority: String?

Gets the encoded authority part of this URI. For server addresses, the authority is structured as follows: {@code userinfo '@' host ':' port }

Link copied to clipboard
abstract val encodedFragment: String?

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

Link copied to clipboard
abstract val encodedPath: String?

Gets the encoded path.

Link copied to clipboard
abstract val encodedQuery: String?

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".

Link copied to clipboard
abstract val encodedSchemeSpecificPart: String?

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.

Link copied to clipboard
abstract val encodedUserInfo: String?

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

Link copied to clipboard
abstract val fragment: String?

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

Link copied to clipboard
abstract val host: String?

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".

Link copied to clipboard
val isAbsolute: Boolean

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

Link copied to clipboard
abstract val isHierarchical: Boolean

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.

Link copied to clipboard
val isOpaque: Boolean

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

Link copied to clipboard
abstract val isRelative: Boolean

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

Link copied to clipboard
abstract val lastPathSegment: String?

Gets the decoded last segment in the path.

Link copied to clipboard
abstract val path: String?

Gets the decoded path.

Link copied to clipboard
abstract val pathSegments: List<String>

Gets the decoded path segments.

Link copied to clipboard
abstract val port: Int

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

Link copied to clipboard
abstract val query: String?

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".

Link copied to clipboard
abstract val scheme: String?

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

Link copied to clipboard
abstract val schemeSpecificPart: String?

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.

Link copied to clipboard
abstract val userInfo: String?

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

Extensions

Link copied to clipboard
fun Uri.toURI(): URI
Link copied to clipboard
fun Uri.toURIOrNull(): URI?
Link copied to clipboard
fun Uri.toURL(): URL
Link copied to clipboard
fun Uri.toURLOrNull(): URL?