Class DefaultDownloadIndex
- java.lang.Object
-
- com.google.android.exoplayer2.offline.DefaultDownloadIndex
-
- All Implemented Interfaces:
DownloadIndex,WritableDownloadIndex
@Deprecated public final class DefaultDownloadIndex extends Object implements WritableDownloadIndex
Deprecated.com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.ADownloadIndexthat uses SQLite to persistDownloads.
-
-
Constructor Summary
Constructors Constructor Description DefaultDownloadIndex(DatabaseProvider databaseProvider)Deprecated.Creates an instance that stores theDownloadsin an SQLite database provided by aDatabaseProvider.DefaultDownloadIndex(DatabaseProvider databaseProvider, String name)Deprecated.Creates an instance that stores theDownloadsin an SQLite database provided by aDatabaseProvider.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description DownloadgetDownload(String id)Deprecated.Returns theDownloadwith the givenid, or null.DownloadCursorgetDownloads(@com.google.android.exoplayer2.offline.Download.State int... states)Deprecated.voidputDownload(Download download)Deprecated.Adds or replaces aDownload.voidremoveDownload(String id)Deprecated.Removes the download with the given ID.voidsetDownloadingStatesToQueued()Deprecated.Sets allDownload.STATE_DOWNLOADINGstates toDownload.STATE_QUEUED.voidsetStatesToRemoving()Deprecated.Sets all states toDownload.STATE_REMOVING.voidsetStopReason(int stopReason)Deprecated.Sets the stop reason of the downloads in a terminal state (Download.STATE_COMPLETED,Download.STATE_FAILED).voidsetStopReason(String id, int stopReason)Deprecated.Sets the stop reason of the download with the given ID in a terminal state (Download.STATE_COMPLETED,Download.STATE_FAILED).
-
-
-
Constructor Detail
-
DefaultDownloadIndex
public DefaultDownloadIndex(DatabaseProvider databaseProvider)
Deprecated.Creates an instance that stores theDownloadsin an SQLite database provided by aDatabaseProvider.Equivalent to calling
DefaultDownloadIndex(DatabaseProvider, String)withname="".Applications that only have one download index may use this constructor. Applications that have multiple download indices should call
DefaultDownloadIndex(DatabaseProvider, String)to specify a unique name for each index.- Parameters:
databaseProvider- Provides the SQLite database in which downloads are persisted.
-
DefaultDownloadIndex
public DefaultDownloadIndex(DatabaseProvider databaseProvider, String name)
Deprecated.Creates an instance that stores theDownloadsin an SQLite database provided by aDatabaseProvider.- Parameters:
databaseProvider- Provides the SQLite database in which downloads are persisted.name- The name of the index. This name is incorporated into the names of the SQLite tables in which downloads are persisted.
-
-
Method Detail
-
getDownload
@Nullable public Download getDownload(String id) throws DatabaseIOException
Deprecated.Description copied from interface:DownloadIndexReturns theDownloadwith the givenid, or null.This method may be slow and shouldn't normally be called on the main thread.
- Specified by:
getDownloadin interfaceDownloadIndex- Parameters:
id- ID of aDownload.- Returns:
- The
Downloadwith the givenid, or null if a download state with this id doesn't exist. - Throws:
DatabaseIOException
-
getDownloads
public DownloadCursor getDownloads(@State @com.google.android.exoplayer2.offline.Download.State int... states) throws DatabaseIOException
Deprecated.Description copied from interface:DownloadIndexReturns aDownloadCursortoDownloads with the givenstates.This method may be slow and shouldn't normally be called on the main thread.
- Specified by:
getDownloadsin interfaceDownloadIndex- Parameters:
states- Returns only theDownloads with this states. If empty, returns all.- Returns:
- A cursor to
Downloads with the givenstates. - Throws:
DatabaseIOException
-
putDownload
public void putDownload(Download download) throws DatabaseIOException
Deprecated.Description copied from interface:WritableDownloadIndexAdds or replaces aDownload.This method may be slow and shouldn't normally be called on the main thread.
- Specified by:
putDownloadin interfaceWritableDownloadIndex- Parameters:
download- TheDownloadto be added.- Throws:
DatabaseIOException
-
removeDownload
public void removeDownload(String id) throws DatabaseIOException
Deprecated.Description copied from interface:WritableDownloadIndexRemoves 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.
- Specified by:
removeDownloadin interfaceWritableDownloadIndex- Parameters:
id- The ID of the download to remove.- Throws:
DatabaseIOException
-
setDownloadingStatesToQueued
public void setDownloadingStatesToQueued() throws DatabaseIOExceptionDeprecated.Description copied from interface:WritableDownloadIndexSets allDownload.STATE_DOWNLOADINGstates toDownload.STATE_QUEUED.This method may be slow and shouldn't normally be called on the main thread.
- Specified by:
setDownloadingStatesToQueuedin interfaceWritableDownloadIndex- Throws:
DatabaseIOException
-
setStatesToRemoving
public void setStatesToRemoving() throws DatabaseIOExceptionDeprecated.Description copied from interface:WritableDownloadIndexSets all states toDownload.STATE_REMOVING.This method may be slow and shouldn't normally be called on the main thread.
- Specified by:
setStatesToRemovingin interfaceWritableDownloadIndex- Throws:
DatabaseIOException
-
setStopReason
public void setStopReason(int stopReason) throws DatabaseIOExceptionDeprecated.Description copied from interface:WritableDownloadIndexSets the stop reason of the downloads in a terminal state (Download.STATE_COMPLETED,Download.STATE_FAILED).This method may be slow and shouldn't normally be called on the main thread.
- Specified by:
setStopReasonin interfaceWritableDownloadIndex- Parameters:
stopReason- The stop reason.- Throws:
DatabaseIOException
-
setStopReason
public void setStopReason(String id, int stopReason) throws DatabaseIOException
Deprecated.Description copied from interface:WritableDownloadIndexSets the stop reason of the download with the given ID in a terminal state (Download.STATE_COMPLETED,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.
- Specified by:
setStopReasonin interfaceWritableDownloadIndex- Parameters:
id- The ID of the download to update.stopReason- The stop reason.- Throws:
DatabaseIOException
-
-