DownloadHelper
Centralized download helper based on Android's DownloadManager.
Handles file downloads to public or private directories with automatic progress tracking and system notifications.
Permissions:
No permissions required for public folder downloads on API 29+.
WRITE_EXTERNAL_STORAGErequired on API < 29.
Example usage:
val downloadHelper = DownloadHelper(context)
val id = downloadHelper.enqueue(
DownloadConfig.publicFile(
url = "https://example.com/report.pdf",
fileName = "rapport.pdf"
)
)
// Observe completion
viewModelScope.launch {
downloadHelper.completionFlow(id).collect { status ->
if (status is DownloadStatus.Success) {
openFile(status.localUri)
}
}
}Content copied to clipboard
Functions
Link copied to clipboard
Flow émettant le DownloadStatus final (Success ou Failed) pour l'id donné. Se ferme automatiquement après émission.
Link copied to clipboard
Starts the download described by config. Returns the download ID.
Link copied to clipboard
Link copied to clipboard
Retourne le statut courant du téléchargement id.