不完整下载的文件处理 [英] Dealing with incomplete downloaded file

查看:193
本文介绍了不完整下载的文件处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有在新的文件可以在用户的​​请求被添加ePub档案的收集。

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

现在,如果用户想下载一个新的ePub文件,因此点击,说获取最新书籍,和书籍开始下载到设备的SD卡。

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后退按钮

  • 他从互联网上断开

  • 他终止应用程序

然后下载文件保持完整。

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.

对此有何想法?

推荐答案

您需要检查文件是否试图打开它之前完全下载。

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

您可以存储下载的完整/共享preference不全,下载完成后,应进行更新的状态。试图加载文件之前检查该preference。

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.

这篇关于不完整下载的文件处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆