In Android¶
In Android, you can add the following dependency
To add a copy interceptor that records download tasks and prioritizes copying for subsequent downloads of the same resource to prevent duplicate downloads
, use the CopyOnExists
mechanism:
val downloader = Downloader.Builder()
.addInterceptor(CopyOnExistsInterceptor(context, 1000))
.build()
Note: The task records use Google's modern Room database.
To add a network interceptor that supports network restrictions
Afterward, you can set network restrictions
val request = DownloadRequest.Builder()
.networkOn(DownloadRequest.NETWORK_WIFI or DownloadRequest.NETWORK_DATA)
.build()
To add a storage interceptor that checks for insufficient disk space and avoids ineffective downloads