WritableDownloadIndex


@WorkerThread
@UnstableApi
interface WritableDownloadIndex : DownloadIndex

Known direct subclasses
DefaultDownloadIndex

A DownloadIndex that uses SQLite to persist Downloads.


A writable index of Downloads.

Summary

Public functions

Unit
putDownload(download: Download!)

Adds or replaces a Download.

Unit

Removes the download with the given ID.

Unit

Sets all STATE_DOWNLOADING states to STATE_QUEUED.

Unit

Sets all states to STATE_REMOVING.

Unit
setStopReason(stopReason: Int)

Sets the stop reason of the downloads in a terminal state (STATE_COMPLETED, STATE_FAILED).

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

Sets the stop reason of the download with the given ID in a terminal state (STATE_COMPLETED, STATE_FAILED).

Inherited functions

From androidx.media3.exoplayer.offline.DownloadIndex
Download?

Returns the Download with the given id, or null.

DownloadCursor!

Returns a DownloadCursor to Downloads with the given states.

Public functions

putDownload

fun putDownload(download: Download!): Unit

Adds or replaces a Download.

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

Parameters
download: Download!

The Download to be added.

Throws
java.io.IOException

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: String!

The ID of the download to remove.

Throws
java.io.IOException

If an error occurs removing the state.

setDownloadingStatesToQueued

fun setDownloadingStatesToQueued(): Unit

Sets all STATE_DOWNLOADING states to STATE_QUEUED.

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

Throws
java.io.IOException

If an error occurs updating the state.

setStatesToRemoving

fun setStatesToRemoving(): Unit

Sets all states to STATE_REMOVING.

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

Throws
java.io.IOException

If an error occurs updating the state.

setStopReason

fun setStopReason(stopReason: Int): Unit

Sets the stop reason of the downloads in a terminal state (STATE_COMPLETED, STATE_FAILED).

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

Parameters
stopReason: Int

The stop reason.

Throws
java.io.IOException

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 (STATE_COMPLETED, 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: String!

The ID of the download to update.

stopReason: Int

The stop reason.

Throws
java.io.IOException

If an error occurs updating the state.