The use of Open source HTTP file download Framework File-downloader

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.