# ContentUris

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Ctors](https://developer.android.com/reference/android/content/ContentUris#pubctors)\|[Methods](https://developer.android.com/reference/android/content/ContentUris#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/content/ContentUris#inhmethods)  

# ContentUris

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/content/ContentUris "View this page in Kotlin")\|Java

`
public


class
ContentUris
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

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

<br />

*** ** * ** ***

Utility methods useful for working with[Uri](https://developer.android.com/reference/android/net/Uri)objects that use the "content" (content://) scheme.

Content URIs have the syntax

`content://`*authority* `/`*path* `/`*id*

`content:`
:   The scheme portion of the URI. This is always set to[ContentResolver.SCHEME_CONTENT](https://developer.android.com/reference/android/content/ContentResolver#SCHEME_CONTENT)(value`content://`).

*authority*
:   A string that identifies the entire content provider. All the content URIs for the provider start with this string. To guarantee a unique authority, providers should consider using an authority that is the same as the provider class' package identifier.

*path*
:   Zero or more segments, separated by a forward slash (`/`), that identify some subset of the provider's data. Most providers use the path part to identify individual tables. Individual segments in the path are often called "directories" although they do not refer to file directories. The right-most segment in a path is often called a "twig"

*id*
:   A unique numeric identifier for a single row in the subset of data identified by the preceding path part. Most providers recognize content URIs that contain an id part and give them special handling. A table that contains a column named`_ID`often expects the id part to be a particular value for that column.

<br />

## Summary

|                                           ### Public constructors                                           ||
|----------------------------------------------------------------------------------------------------------|---|
| ` `[ContentUris](https://developer.android.com/reference/android/content/ContentUris#ContentUris())`() ` |

|                                                                                                                                                                            ### Public methods                                                                                                                                                                             ||
|------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` static `[Uri.Builder](https://developer.android.com/reference/android/net/Uri.Builder) | ` `[appendId](https://developer.android.com/reference/android/content/ContentUris#appendId(android.net.Uri.Builder,%20long))`(`[Uri.Builder](https://developer.android.com/reference/android/net/Uri.Builder)` builder, long id) ` Appends the given ID to the end of the path. |
| ` static long`                                                                           | ` `[parseId](https://developer.android.com/reference/android/content/ContentUris#parseId(android.net.Uri))`(`[Uri](https://developer.android.com/reference/android/net/Uri)` contentUri) ` Converts the last path segment to a long.                                            |
| ` static `[Uri](https://developer.android.com/reference/android/net/Uri)                 | ` `[removeId](https://developer.android.com/reference/android/content/ContentUris#removeId(android.net.Uri))`(`[Uri](https://developer.android.com/reference/android/net/Uri)` contentUri) ` Removes any ID from the end of the path.                                           |
| ` static `[Uri](https://developer.android.com/reference/android/net/Uri)                 | ` `[withAppendedId](https://developer.android.com/reference/android/content/ContentUris#withAppendedId(android.net.Uri,%20long))`(`[Uri](https://developer.android.com/reference/android/net/Uri)` contentUri, long id) ` Appends the given ID to the end of the path.          |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](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 `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](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`                                                                  | ` `[wait](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`                                                                  | ` `[wait](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*.                                                                                             | ||

## Public constructors

### ContentUris

```
public ContentUris ()
```

<br />

<br />

## Public methods

### appendId

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

```
public static Uri.Builder appendId (Uri.Builder builder, 
                long id)
```

Appends the given ID to the end of the path.

<br />

|                                    Parameters                                    ||
|-----------|-----------------------------------------------------------------------|
| `builder` | `Uri.Builder`: to append the ID to This value cannot be`null`. <br /> |
| `id`      | `long`: to append <br />                                              |

|                                                               Returns                                                                ||
|--------------------------------------------------------------------------------|------------------------------------------------------|
| [Uri.Builder](https://developer.android.com/reference/android/net/Uri.Builder) | the given builder This value cannot be`null`. <br /> |

### parseId

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

```
public static long parseId (Uri contentUri)
```

Converts the last path segment to a long.

This supports a common convention for content URIs where an ID is stored in the last segment.

<br />

|                       Parameters                        ||
|--------------|-------------------------------------------|
| `contentUri` | `Uri`: This value cannot be`null`. <br /> |

|                                      Returns                                      ||
|--------|---------------------------------------------------------------------------|
| `long` | the long conversion of the last segment or -1 if the path is empty <br /> |

|                                                                        Throws                                                                        ||
|------------------------------------------------------------------------------------------------------------------|------------------------------------|
| [UnsupportedOperationException](https://developer.android.com/reference/java/lang/UnsupportedOperationException) | if this isn't a hierarchical URI   |
| [NumberFormatException](https://developer.android.com/reference/java/lang/NumberFormatException)                 | if the last segment isn't a number |

### removeId

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

```
public static Uri removeId (Uri contentUri)
```

Removes any ID from the end of the path.

<br />

|                                  Parameters                                  ||
|--------------|----------------------------------------------------------------|
| `contentUri` | `Uri`: that ends with an ID This value cannot be`null`. <br /> |

|                                                                          Returns                                                                          ||
|----------------------------------------------------------------|-------------------------------------------------------------------------------------------|
| [Uri](https://developer.android.com/reference/android/net/Uri) | a new URI with the ID removed from the end of the path This value cannot be`null`. <br /> |

|                                                                                 Throws                                                                                  ||
|--------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | when the given URI has no ID to remove from the end of the path |

### withAppendedId

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

```
public static Uri withAppendedId (Uri contentUri, 
                long id)
```

Appends the given ID to the end of the path.

<br />

|                              Parameters                               ||
|--------------|---------------------------------------------------------|
| `contentUri` | `Uri`: to start with This value cannot be`null`. <br /> |
| `id`         | `long`: to append <br />                                |

|                                                                            Returns                                                                             ||
|----------------------------------------------------------------|------------------------------------------------------------------------------------------------|
| [Uri](https://developer.android.com/reference/android/net/Uri) | a new URI with the given ID appended to the end of the path This value cannot be`null`. <br /> |