# 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)

*** ** * ** ***


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

<br />

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

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

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

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

*** ** * ** ***

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

## Summary

| ### Public methods |
|---|---|
| `abstract @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/offline/Download` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadIndex#getDownload(java.lang.String)(https://developer.android.com/reference/java/lang/String.html id)` Returns the `https://developer.android.com/reference/androidx/media3/exoplayer/offline/Download` with the given `id`, or null. |
| `abstract https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadCursor` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadIndex#getDownloads(int...)(@https://developer.android.com/reference/androidx/media3/exoplayer/offline/Download.State int[] states)` Returns a `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadCursor` to `https://developer.android.com/reference/androidx/media3/exoplayer/offline/Download`s with the given `states`. |

## Public methods

### getDownload

```
abstract @Nullable Download getDownload(String id)
```

Returns the `https://developer.android.com/reference/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 |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html id` | ID of a `https://developer.android.com/reference/androidx/media3/exoplayer/offline/Download`. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/exoplayer/offline/Download` | The `https://developer.android.com/reference/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

```
abstract DownloadCursor getDownloads(@Download.State int[] states)
```

Returns a `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadCursor` to `https://developer.android.com/reference/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/androidx/media3/exoplayer/offline/Download.State int[] states` | Returns only the `https://developer.android.com/reference/androidx/media3/exoplayer/offline/Download`s with this states. If empty, returns all. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadCursor` | A cursor to `https://developer.android.com/reference/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. |