DEV Community

Jeetarc for SimpleDownloader

Posted on Edited on

SimpleDownloader - a modern Android file downloader library designed to simplify complex download management

Downloading files on Android is a headache. You have to deal with file systems, scoped storage, MediaStore, foreground, notifications, lifecycle handling, retries, etc along with optimizations.

Introducing SimpleDownloader - a simple to use library for everything from basic file downloads to advanced download management system.

It supports:

  • Multiple downloader profiles in a single app
  • Queues, priorities, and concurrency control
  • Pause, resume, cancel, retry, remove, requeue, and force download
  • Network loss handling + Wi-Fi-only mode
  • Database persistence and automatic restore
  • Filesystem paths, SAF/Document Tree, and MediaStore
  • Automatic filename and MIME type handling
  • Progress, speed, ETA, status, and lifecycle callbacks
  • Foreground + progress/complete/error notifications, with actions and thumbnails
  • Custom OkHttpClient, headers, cookies, checksums, RetryPolicy, timeouts, and more

Minimum Android version API 21 (Android 5.0). The below examples are written in Java, the library can be used from both Java and Kotlin.

Installation

Add JitPack to your repositories:

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven { url "https://jitpack.io" }
    }
}
Enter fullscreen mode Exit fullscreen mode

Then add the dependency:

dependencies {
    implementation "com.github.jeetarc:SimpleDownloader:<latest-version>"
}
Enter fullscreen mode Exit fullscreen mode

Visit Releases page to know latest version:
https://github.com/jeetarc/SimpleDownloader/releases

Quick Start

// Get the default instance
SimpleDownloader downloader = SimpleDownloader.getInstance(context);

// Or create a customized instance
SimpleDownloader downloader = new SimpleDownloader.Builder(context)
    .setMaxConcurrent(3)
    .setRetryCount(3)
    .enableHistory(true)
    .enableForeground(true)
    .setAutoRestore(true)
    .build();

// Filesystem path
DownloadRequest request = DownloadRequest.from(folderPath, FileName.AUTO, fileUrl);
DownloadTask task = downloader.startDownload(request);

// MediaStore (Android 10+)
DownloadRequest request = DownloadRequest.from(MediaStore.Downloads.EXTERNAL_CONTENT_URI, FileName.AUTO, fileUrl);
DownloadTask task = downloader.startDownload(request);

// SAF / Document Tree
DownloadRequest request = DownloadRequest.from(treeUri, FileName.AUTO, fileUrl);
DownloadTask task = downloader.startDownload(request);
Enter fullscreen mode Exit fullscreen mode

The API also gives callbacks for pause, resume, progress, completion, errors, status changes, lifecycle events, etc. Callbacks and Listeners

Permissions

Only request what you use:

  • POST_NOTIFICATIONS for notifications (runtime permission on Android 13+)
  • FOREGROUND_SERVICE + FOREGROUND_SERVICE_DATA_SYNC when using foreground mode
  • Storage permissions only when writing to external filesystem paths

No storage permission is needed for app-specific directories, MediaStore, or SAF. Setup guide

There are many more APIs, customization and control available, view README for more: https://github.com/jeetarc/SimpleDownloader/blob/main/README.md

GitHub: https://github.com/jeetarc/SimpleDownloader

Reddit community: https://www.reddit.com/r/SimpleDownloader

I'd love to hear your feedback, especially if you've dealing with Android's download/storage APIs before.

Top comments (0)