Android: loading a single file in many parts

I am developing an application such as Internet Download Manager for Android.

I want to know how to upload various parts of a file in Android, as is done in IDM.

How can I get file metadata before downloading and how to download files in parts?

There is no user password in the download or any restrictions ... just download by URL.

+7
source share
1 answer

Assuming you are using HTTP for download, you will want to use the HEAD http verb and RANGE http headers.

HEAD will give you the file size (if available), and then RANGE allows you to load a range of bytes.

Once you have the file size, split it into pieces of the same size and find the download stream for each fragment. Once done, write the file fragments in the correct order.

EDIT:

If you do not know how to use the RANGE header, here is another SO answer that explains how:

+6
source

All Articles