# DownloadIndex

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/DownloadIndex.java+class:androidx.media3.exoplayer.offline.DownloadIndex)

*** ** * ** ***

<br />

```
@WorkerThread
@UnstableApi
interface DownloadIndex
```

<br />

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

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

Known indirect 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`. |

*** ** * ** ***

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

## Summary

| ### Public functions |
|---|---|
| `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

### getDownload

```
fun getDownload(id: String!): Download?
```

Returns the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download` with the given `id`, or null.

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!` | ID of a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download?` | The `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download` with the given `id`, or null if a download state with this id doesn't exist. |

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

### getDownloads

```
fun getDownloads(@Download.State states: IntArray<Int>!): DownloadCursor!
```

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

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

| Parameters |
|---|---|
| `@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 only the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download`s with this states. If empty, returns all. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/DownloadCursor!` | A cursor to `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/offline/Download`s with the given `states`. |

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