WritableDownloadIndex


@WorkerThread
@UnstableApi
public interface WritableDownloadIndex extends DownloadIndex

Known direct subclasses
DefaultDownloadIndex

A DownloadIndex that uses SQLite to persist Downloads.


A writable index of Downloads.

Summary

Public methods

abstract void

Adds or replaces a Download.

abstract void

Removes the download with the given ID.

abstract void

Sets all STATE_DOWNLOADING states to STATE_QUEUED.

abstract void

Sets all states to STATE_REMOVING.

abstract void
setStopReason(int stopReason)

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

abstract void
setStopReason(String id, int stopReason)

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

Inherited methods

From androidx.media3.exoplayer.offline.DownloadIndex
abstract @Nullable Download

Returns the Download with the given id, or null.

abstract DownloadCursor

Returns a DownloadCursor to Downloads with the given states.

Public methods

putDownload

abstract void putDownload(Download download)

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

abstract void removeDownload(String id)

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
String id

The ID of the download to remove.

Throws
java.io.IOException

If an error occurs removing the state.

setDownloadingStatesToQueued

abstract void setDownloadingStatesToQueued()

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

abstract void setStatesToRemoving()

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

abstract void setStopReason(int stopReason)

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
int stopReason

The stop reason.

Throws
java.io.IOException

If an error occurs updating the state.

setStopReason

abstract void setStopReason(String id, int stopReason)

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
String id

The ID of the download to update.

int stopReason

The stop reason.

Throws
java.io.IOException

If an error occurs updating the state.