Android Multi-threaded breakpoint continued download

Source: Internet
Author: User
Tags sqlite database

This month received a project to write a software management app like the 360 assistant, where a problem was encountered: Multi-threaded Breakpoint Download

This, because previously did not write this aspect of the application function. So, it is inevitable to self-study. Then you pick up the cables at each ANG station and sort them out. Sharing with you can also deepen my understanding in this respect.

What is multi-threaded download?

Multi-threaded download is actually thunder, bt some download principle, through a number of threads at the same time and the server connection, then you can squeeze the higher bandwidth, the general practice is to cut the file into n blocks, each piece to a separate thread to download, the respective download is completed after the file block into a file, Program to complete the cutting and assembly of the small algorithm

What is a breakpoint continuation?

Breakpoint continuation, that is, when we download the end of the time, the exit to save the download progress, when the next time you open and continue to download the last progress continues to download, do not have to restart each download, then the principle of the continuation of the breakpoint and implementation means.

How to complete multi-threaded breakpoint continuation?

Combining the two requires the program to remember the download progress of each file block, and save the storage, when the download program starts when you need to determine whether the program has downloaded the file, and take out the individual file block record, the download progress to continue to download, here you need to master Java Multi-Threading basic knowledge, The use of handler, as well as the collection, algorithm, file operation and other basic skills, but also to solve the SQLite database synchronization problem, because it is not very how to support multi-threaded operation, control is not good often there is a library locked exception, At the same time after android2.3 can not operate directly in the activity HTTP, otherwise you will receive the system sent on the networkonmainthreadexception exception, in the UI experience must remember to use asynchronous completion.

Well, after the understanding of these and then look at the source code will be pulled knot ...

Take a look first:


--------------------------------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------------------


As for those parts of the code, I am not posted here, I think it is convenient to see the source code directly.

here is the source of the download URL, click to download

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.