### Get Download Request Status Source: https://github.com/amitshekhariitbhu/prdownloader/blob/master/README.md Retrieve the current status of a download request using its download ID. ```java Status status = PRDownloader.getStatus(downloadId); ``` -------------------------------- ### Initialize PRDownloader with Database Enabled Source: https://github.com/amitshekhariitbhu/prdownloader/blob/master/README.md Initialize PRDownloader with database support enabled for resume capabilities, even after the application is killed. ```java // Enabling database for resume support even after the application is killed: PRDownloaderConfig config = PRDownloaderConfig.newBuilder() .setDatabaseEnabled(true) .build(); PRDownloader.initialize(getApplicationContext(), config); ``` -------------------------------- ### Make a Download Request Source: https://github.com/amitshekhariitbhu/prdownloader/blob/master/README.md Initiate a download request with various listeners for progress, start/resume, pause, cancel, and completion/error events. ```java int downloadId = PRDownloader.download(url, dirPath, fileName) .build() .setOnStartOrResumeListener(new OnStartOrResumeListener() { @Override public void onStartOrResume() { } }) .setOnPauseListener(new OnPauseListener() { @Override public void onPause() { } }) .setOnCancelListener(new OnCancelListener() { @Override public void onCancel() { } }) .setOnProgressListener(new OnProgressListener() { @Override public void onProgress(Progress progress) { } }) .start(new OnDownloadListener() { @Override public void onDownloadComplete() { } @Override public void onError(Error error) { } }); ``` -------------------------------- ### Initialize PRDownloader Source: https://github.com/amitshekhariitbhu/prdownloader/blob/master/README.md Initialize the PRDownloader library in the onCreate() method of your application class. ```java PRDownloader.initialize(getApplicationContext()); ``` -------------------------------- ### Initialize PRDownloader with Custom Timeouts Source: https://github.com/amitshekhariitbhu/prdownloader/blob/master/README.md Initialize PRDownloader with custom read and connect timeouts for network requests. ```java // Setting timeout globally for the download network requests: PRDownloaderConfig config = PRDownloaderConfig.newBuilder() .setReadTimeout(30_000) .setConnectTimeout(30_000) .build(); PRDownloader.initialize(getApplicationContext(), config); ``` -------------------------------- ### Add JitPack Repository to settings.gradle Source: https://github.com/amitshekhariitbhu/prdownloader/blob/master/README.md Include the JitPack repository in your project's settings.gradle file to fetch the PRDownloader library. ```groovy maven { url 'https://jitpack.io' } ``` -------------------------------- ### Add JitPack Repository to settings.gradle.kts Source: https://github.com/amitshekhariitbhu/prdownloader/blob/master/README.md Include the JitPack repository in your project's settings.gradle.kts file for Kotlin DSL projects. ```kotlin maven { setUrl("https://jitpack.io") } ``` -------------------------------- ### Add PRDownloader Dependency to build.gradle.kts Source: https://github.com/amitshekhariitbhu/prdownloader/blob/master/README.md Add the PRDownloader library dependency using Kotlin DSL in your app's build.gradle.kts file. ```kotlin implementation("com.github.amitshekhariitbhu:PRDownloader:1.0.2") ``` -------------------------------- ### Resume a Download Request Source: https://github.com/amitshekhariitbhu/prdownloader/blob/master/README.md Resume a previously paused download request using its download ID. ```java PRDownloader.resume(downloadId); ``` -------------------------------- ### Add PRDownloader Dependency to build.gradle Source: https://github.com/amitshekhariitbhu/prdownloader/blob/master/README.md Add the PRDownloader library dependency to your app's build.gradle file. ```groovy implementation 'com.github.amitshekhariitbhu:PRDownloader:1.0.2' ``` -------------------------------- ### Clean Up Resumed Files Source: https://github.com/amitshekhariitbhu/prdownloader/blob/master/README.md Clean up temporary resumed files that are older than a specified number of days, useful when database is enabled. ```java // Method to clean up temporary resumed files which is older than the given day PRDownloader.cleanUp(days); ``` -------------------------------- ### PRDownloader Apache 2.0 License Source: https://github.com/amitshekhariitbhu/prdownloader/blob/master/README.md This snippet displays the full Apache 2.0 license text. It governs the use, modification, and distribution of the PRDownloader library. ```text Copyright (C) 2024 Amit Shekhar Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ``` -------------------------------- ### Add Internet Permission to Manifest Source: https://github.com/amitshekhariitbhu/prdownloader/blob/master/README.md Ensure your AndroidManifest.xml includes the internet permission if it's not already present. ```xml ``` -------------------------------- ### Cancel Download Requests Source: https://github.com/amitshekhariitbhu/prdownloader/blob/master/README.md Cancel download requests by ID, tag, or cancel all active downloads. ```java // Cancel with the download id PRDownloader.cancel(downloadId); // The tag can be set to any request and then can be used to cancel the request PRDownloader.cancel(TAG); // Cancel all the requests PRDownloader.cancelAll(); ``` -------------------------------- ### Pause a Download Request Source: https://github.com/amitshekhariitbhu/prdownloader/blob/master/README.md Pause an ongoing download request using its unique download ID. ```java PRDownloader.pause(downloadId); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.