# UriUtil
=======

Artifact: [androidx.media3:media3-common](/jetpack/androidx/releases/media3)  
[View Source](https://cs.android.com/search?q=file:androidx/media3/common/util/UriUtil.java+class:androidx.media3.common.util.UriUtil)

*** ** * ** ***

Kotlin \|[Java](/reference/androidx/media3/common/util/UriUtil "View this page in Java")


```
@UnstableApi
class UriUtil
```

<br />

*** ** * ** ***

Utility methods for manipulating URIs.

Summary
-------

|                                        ### Public functions                                        |
|----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `java-static `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!` | `@`[UnstableApi](/reference/kotlin/androidx/media3/common/util/UnstableApi) [getRelativePath](/reference/kotlin/androidx/media3/common/util/UriUtil#getRelativePath(android.net.Uri,android.net.Uri))`(baseUri: `[Uri](https://developer.android.com/reference/android/net/Uri.html)`!, targetUri: `[Uri](https://developer.android.com/reference/android/net/Uri.html)`!)` Calculates the relative path from a base URI to a target URI.                                                                                                                                                                            |
| `java-static `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)  | [isAbsolute](/reference/kotlin/androidx/media3/common/util/UriUtil#isAbsolute(java.lang.String))`(uri: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?)` Returns true if the URI is starting with a scheme component, false otherwise.                                                                                                                                                                                                                                                                                                                                          |
| `java-static `[Uri](https://developer.android.com/reference/android/net/Uri.html)`!`               | [removeQueryParameter](/reference/kotlin/androidx/media3/common/util/UriUtil#removeQueryParameter(android.net.Uri,java.lang.String))`(uri: `[Uri](https://developer.android.com/reference/android/net/Uri.html)`!, queryParameterName: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!)` Removes query parameter from a URI, if present.                                                                                                                                                                                                                                        |
| `java-static `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!` | [resolve](/reference/kotlin/androidx/media3/common/util/UriUtil#resolve(java.lang.String,java.lang.String))`(baseUri: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?, referenceUri: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?)` Performs relative resolution of a `referenceUri` with respect to a `baseUri`.                                                                                                                                                                                                                       |
| `java-static `[Uri](https://developer.android.com/reference/android/net/Uri.html)`!`               | [resolveToUri](/reference/kotlin/androidx/media3/common/util/UriUtil#resolveToUri(java.lang.String,java.lang.String))`(baseUri: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?, referenceUri: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?)` Like [resolve](/reference/kotlin/androidx/media3/common/util/UriUtil#resolve(java.lang.String,java.lang.String)), but returns a [Uri](https://developer.android.com/reference/android/net/Uri.html) instead of a [String](https://developer.android.com/reference/java/lang/String.html). |

Public functions
----------------

### getRelativePath

```
@UnstableApi
java-static fun getRelativePath(baseUri: Uri!, targetUri: Uri!): String!
```

Calculates the relative path from a base URI to a target URI.  

|                                       Returns                                        |
|--------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------|
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!` | The relative path from the base URI to the target URI, or `targetUri` if the URIs have different schemes or authorities. |

### isAbsolute

```
java-static fun isAbsolute(uri: String?): Boolean
```

Returns true if the URI is starting with a scheme component, false otherwise.  

### removeQueryParameter

```
java-static fun removeQueryParameter(uri: Uri!, queryParameterName: String!): Uri!
```

Removes query parameter from a URI, if present.  

|                                                 Parameters                                                 |
|------------------------------------------------------------------------------------------------------------|----------------------------------|
| `uri: `[Uri](https://developer.android.com/reference/android/net/Uri.html)`!`                              | The URI.                         |
| `queryParameterName: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!` | The name of the query parameter. |

|                                Returns                                 |
|------------------------------------------------------------------------|--------------------------------------|
| [Uri](https://developer.android.com/reference/android/net/Uri.html)`!` | The URI without the query parameter. |

### resolve

```
java-static fun resolve(baseUri: String?, referenceUri: String?): String!
```

Performs relative resolution of a `referenceUri` with respect to a `baseUri`.

The resolution is performed as specified by RFC-3986.  

|                                              Parameters                                              |
|------------------------------------------------------------------------------------------------------|-------------------------------|
| `baseUri: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?`      | The base URI.                 |
| `referenceUri: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?` | The reference URI to resolve. |

### resolveToUri

```
java-static fun resolveToUri(baseUri: String?, referenceUri: String?): Uri!
```

Like [resolve](/reference/kotlin/androidx/media3/common/util/UriUtil#resolve(java.lang.String,java.lang.String)), but returns a [Uri](https://developer.android.com/reference/android/net/Uri.html) instead of a [String](https://developer.android.com/reference/java/lang/String.html).  

|                                              Parameters                                              |
|------------------------------------------------------------------------------------------------------|-------------------------------|
| `baseUri: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?`      | The base URI.                 |
| `referenceUri: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`?` | The reference URI to resolve. |