简体   繁体   中英

Most efficient way of downloading large amounts of data to android?

I have an external database on Azure that holds large amounts of information. My app needs to be able to synchronize a selection of this data and store it locally on the app's database. I currently use web services to make calls to the database. When the app starts for the first time, it will have a large amount of data that would need to be downloaded. What's the most efficient way of downloading a large number of rows from the external database? I was thinking an XML file might be the best way, but I'm not sure. There could be thousands of rows that need downloading so I'm not sure which method would be the most appropriate.

There isn't 300 ways to download data, so you'll basically have to call your API and get the data. For obvious performance reasons, I would avoid XML and prefere JSON instead. So once you've got your JSON file, you parse it and put it in the locale database. I also would suggest you to use service as it won't be interupt, and don't forget to warn the user that you gonna download massive data ;)

If you wan't to minimize the amount of data downloaded, you can store a JSON file for example in the assets that will contains all the things "static" that won't change online.

I would offload the work to some sort of service . Services have the benefit of running in the background without interacting with the application. You would still need to create another thread to do the work. When the download is finished, it will simply destroy itself.

无论使用哪种方法,都应该下载数据,也许您可​​以将初始数据准备为XML文件,第一次下载并将其存储在数据库中,并向用户显示进度条

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM