Scorpion
Scorpion

Reputation: 6891

Puling big data from Web Service in Android efficiently

I am having one web service in which i have list of countries, state and corresponding cities of it. Now I am little bit confused in pulling this data in my Android app. Right now I have only 2(USA,Canada) Country data with me but it might be increased in future. Also I have list of state in this country and yes the cities in every state.

I have one splash screen in my app in which I have written the logic of getting country and on the basis of that i am getting state and then cities for every state. But its long process and if i publish this a user will be frustrated by waiting time. So I don't want to use this way which takes longer time for pulling data. Is there any other way or suggestion for me to achieve this.

All suggestions are welcome.

Upvotes: 3

Views: 734

Answers (3)

rgrocha
rgrocha

Reputation: 1461

You could simple use the system DownloadManager to get the files from your sources and later process them. The DownloadManager will even inform you when the file is fully downloaded.

Take a look a https://github.com/commonsguy/cw-android/blob/master/Internet/Download/src/com/commonsware/android/download/DownloadDemo.java for a simple example code using DownloadManager.

Upvotes: 0

lenik
lenik

Reputation: 23498

you should use AsyncTask to perform any web data downloading (and uploading), it works in the background and does not block UI thread, so your user won't notice.

also, it might be a good idea to supply default country/city data along with your application and then download only changes/updates.

Upvotes: 1

arvchak
arvchak

Reputation: 56

Use a Service or intent-service, to download the data in background. and when the download is complete you can display the downloaded data using onbind. service runs on a seperate thread.

Upvotes: 0

Related Questions