简体   繁体   中英

What is the best way to download large amount of data and save it without locking the phone (Android Studio)

I am working on an Android project (JAVA), but i need to download many line of a database from a server like 3.5K lines , my questions is - what is the best way to download large data without letting the phone become slow , because i used Retrofit and also XmlAsyncTask , but cos of the data to download are much , as I download each time the phone almost crashes,

despite the fact that i used background threads. so what is the best way to do to avoid the phone crash with eavy data.

Thanks.

Maybe you are receiving to much data in one request, this data is stored in memory before it can saved in another source and this is the reason that block your phone. The way to use retrofit and background thread is the correct, so you only have to manage the way that you are receiving the data, get it in small amounts recursively and store it in a physical source. I suggest RXJava or Kotlin Coroutines for this kind of operations because is easier and works very well together. I hope that it works for you. Regards.

In any scenario you should contemplate a reconstruction scenario. In that case, you maintain the request alive? Maybe you can divide a huge request into a small and successive requests...

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