Dealing with incomplete downloaded file

久未见 提交于 2019-12-08 04:18:51

问题


I have collection of ePub files in which new files can be added on user's request.

Now if user wants to download a new ePub file and hence clicks on, say get latest book, and book starts downloading to device sdcard.

Now before download gets completed, if user

  • presses back button
  • he is disconnected from internet
  • he terminates the application

then downloaded file remains incomplete.

When next time user opens the app, it tries to open that incomplete file resulting in possible crash of the app.

Any idea on this?


回答1:


You need to check if the file is fully downloaded before attempting to open it.

You could store the status of the download as complete/incomplete in shared preference, which should be updated when the download is complete. Check this preference before trying to load the file.



来源:https://stackoverflow.com/questions/11557893/dealing-with-incomplete-downloaded-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!