# UriUtil

Artifact: [androidx.media3:media3-common](https://developer.android.com/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)

*** ** * ** ***


```
@UnstableApi
public final class UriUtil
```

<br />

*** ** * ** ***

Utility methods for manipulating URIs.

## Summary

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

## Public methods

### getRelativePath

```
@UnstableApi
public static String getRelativePath(Uri baseUri, Uri targetUri)
```

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

| Returns |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html` | The relative path from the base URI to the target URI, or `targetUri` if the URIs have different schemes or authorities. |

### isAbsolute

```
public static boolean isAbsolute(@Nullable String uri)
```

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

### removeQueryParameter

```
public static Uri removeQueryParameter(Uri uri, String queryParameterName)
```

Removes query parameter from a URI, if present.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/net/Uri.html uri` | The URI. |
| `https://developer.android.com/reference/java/lang/String.html queryParameterName` | The name of the query parameter. |

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

### resolve

```
public static String resolve(@Nullable String baseUri, @Nullable String referenceUri)
```

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

The resolution is performed as specified by RFC-3986.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html baseUri` | The base URI. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html referenceUri` | The reference URI to resolve. |

### resolveToUri

```
public static Uri resolveToUri(@Nullable String baseUri, @Nullable String referenceUri)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html baseUri` | The base URI. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html referenceUri` | The reference URI to resolve. |