File-downloader (Https://github.com/wlfcolin/file-downloader) is my open source of an HTTP file download framework, is based on your own experience summarized a set of simple very lightweight android generic HTTP file download manager.
Features: Support for breakpoint continuation, multi-task download, rename, move, delete, custom download name and save path, etc.
File-downloader uses a similar design architecture as the Android image loading framework, which is described in the following instructions and Image-loader:
1. Initialize Filedownloadmanager in your application's OnCreate () method
1.create Filedownloadconfiguration.builder
Builder Builder =New Filedownloadconfiguration.builder (This;
2.builder Filedownloadconfiguration.builder
Builder.configfiledownloaddir (Environment.getExternalStorageDirectory (). GetAbsolutePath () + File. separator + "Filedownloader"); Config the download path
Builder.configdownloadtasksize (3); Allow 3 download task at the same time
Filedownloadconfiguration configuration = Builder.build (); Config filedownloadconfiguration with the builder
3.init Filedownloadmanager with the configuration
Filedownloadmanager. getinstance (this). Init (configuration);
2. Create a new download
Mfiledownloadmanager.start (URLmonfiledownloadstatuslistener);
3. Create a custom save file name and storage path download
Mfiledownloadmanager.detect (URL, new Ondetecturlfilelistener () {
@Override
public voidOndetectnewdownloadfile (String URL, String FileName, String Savedir, int fileSize) {
Change Filename,savedir if needed
Mfiledownloadmanager.createandstart (URL, Newfiledir, NewFileName,Monfiledownloadstatuslistener) "
@Override
public void ondetecturlfileexist (String URL) {
Span style= "color: #9876aa;" >mfiledownloadmanager.start (Url Monfiledownloadstatuslistener)
@Override
public void ondetecturlfilefailed (String url //error
})
4. Continue with a paused download
Mfiledownloadmanager.start (URLmonfiledownloadstatuslistener);
5. Delete the download
5-1. Delete a single
Mfiledownloadmanager.delete (URL, True, Mondeletedownloadfilelistener); Single File
5-2. Delete multiple
Mfiledownloadmanager.delete (URLs, True, Mondeletedownloadfileslistener); Multi Files
6. Move the download file to the new folder
6-1. Move a single
Mfiledownloadmanager.move (URL, Newdirpath, Monmovedownloadfilelistener); Single file
6-2. Move multiple
Mfiledownloadmanager.move (URLs, Newdirpath, Monmovedownloadfileslistener); Multi Files
7. Rename the download file
Mfiledownloadmanager.rename (URL, NewName, True, Monrenamedownloadfilelistener);
----------------End----------------
The use of Open source HTTP file download Framework File-downloader