Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fetching big amount of data, what is the best way to go?

Tags:

I have severals URLs I need to get data from, this should happen in order, one by one. The amount of data returned by requesting those URLs is relatively big. I need to be able to reschedule particular downloads which failed.

What is the best way to go? Shall I use IntentService, Loaders or something else?

Additional note: I would need not only to download, but also post process the data (create tables in db, fill it with data, etc). So DownloadManger can't be of help here.

like image 583
Eugene Avatar asked Jun 29 '13 08:06

Eugene


1 Answers

I would use an IntentService.

It has a number of advantages that are suitable for your needs, including being able to download the data without your application running and supporting automatic restart of the service using setIntentRedelivery().

You can set a number of identifiers for the particular job, you need to perform using Intent extras, and you can keep track of the progress using SharedPreferences - that way you can also resume the work if it's been cancelled previously.

like image 141
Michell Bak Avatar answered Sep 22 '22 17:09

Michell Bak