# WritableDownloadIndex

Artifact: [androidx.media3:media3-exoplayer](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/exoplayer/offline/WritableDownloadIndex.java+class:androidx.media3.exoplayer.offline.WritableDownloadIndex)

*** ** * ** ***

<br />

```
@WorkerThread
@UnstableApi
interface WritableDownloadIndex : DownloadIndex
```

<br />

Known direct subclasses [DefaultDownloadIndex](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DefaultDownloadIndex)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DefaultDownloadIndex` | A `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadIndex` that uses SQLite to persist `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download`. |

*** ** * ** ***

A writable index of `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download`.

## Summary

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/WritableDownloadIndex#putDownload(androidx.media3.exoplayer.offline.Download)(download: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download!)` Adds or replaces a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/WritableDownloadIndex#removeDownload(java.lang.String)(id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` Removes the download with the given ID. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/WritableDownloadIndex#setDownloadingStatesToQueued()()` Sets all `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download#STATE_DOWNLOADING()` states to `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download#STATE_QUEUED()`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/WritableDownloadIndex#setStatesToRemoving()()` Sets all states to `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download#STATE_REMOVING()`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/WritableDownloadIndex#setStopReason(int)(stopReason: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the stop reason of the downloads in a terminal state (`https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download#STATE_COMPLETED()`, `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download#STATE_FAILED()`). |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/WritableDownloadIndex#setStopReason(java.lang.String,int)(id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, stopReason: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the stop reason of the download with the given ID in a terminal state (`https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download#STATE_COMPLETED()`, `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download#STATE_FAILED()`). |

### Inherited functions

From [androidx.media3.exoplayer.offline.DownloadIndex](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadIndex) `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download?` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadIndex#getDownload(java.lang.String)(id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)`

Returns the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download` with the given `id`, or null.
`https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadCursor!` `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadIndex#getDownloads(int...)(@https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download.State states: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!)`

Returns a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadCursor` to `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download`s with the given `states`.

## Public functions

### putDownload

```
fun putDownload(download: Download!): Unit
```

Adds or replaces a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download`.

This method may be slow and shouldn't normally be called on the main thread.

| Parameters |
|---|---|
| `download: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download!` | The `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download` to be added. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurs setting the state. |

### removeDownload

```
fun removeDownload(id: String!): Unit
```

Removes the download with the given ID. Does nothing if a download with the given ID does not exist.

This method may be slow and shouldn't normally be called on the main thread.

| Parameters |
|---|---|
| `id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The ID of the download to remove. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurs removing the state. |

### setDownloadingStatesToQueued

```
fun setDownloadingStatesToQueued(): Unit
```

Sets all `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download#STATE_DOWNLOADING()` states to `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download#STATE_QUEUED()`.

This method may be slow and shouldn't normally be called on the main thread.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurs updating the state. |

### setStatesToRemoving

```
fun setStatesToRemoving(): Unit
```

Sets all states to `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download#STATE_REMOVING()`.

This method may be slow and shouldn't normally be called on the main thread.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurs updating the state. |

### setStopReason

```
fun setStopReason(stopReason: Int): Unit
```

Sets the stop reason of the downloads in a terminal state (`https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download#STATE_COMPLETED()`, `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download#STATE_FAILED()`).

This method may be slow and shouldn't normally be called on the main thread.

| Parameters |
|---|---|
| `stopReason: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The stop reason. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurs updating the state. |

### setStopReason

```
fun setStopReason(id: String!, stopReason: Int): Unit
```

Sets the stop reason of the download with the given ID in a terminal state (`https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download#STATE_COMPLETED()`, `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download#STATE_FAILED()`). Does nothing if a download with the given ID does not exist, or if it's not in a terminal state.

This method may be slow and shouldn't normally be called on the main thread.

| Parameters |
|---|---|
| `id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The ID of the download to update. |
| `stopReason: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The stop reason. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurs updating the state. |