当SD卡满则抛出IOException [英] IOException is thrown when SDCard is full

查看:150
本文介绍了当SD卡满则抛出IOException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下载文件并将其保存到SD卡,并希望捕获事件时,SD卡已满。现在它抛出IOException异常,如果没有记忆留在SD卡。

I am downloading files and saving them to SDCard and want to capture a event when SDCard is full. Right now it throws IOException if no memory is left on SDCard.

如何区分内存已满例外,那么其他的IOExceptions?

How to distinguish the memory full exception then the other IOExceptions?

干杯,
Prateek

Cheers, Prateek

推荐答案

如果你知道你有多少数据写入到SD卡上,你可以检查是否有足够的空间,你试图完全写,从而避免IOException异常前

If you know how much data you are writing to the SD card, you could check whether there is sufficient space before you try to write and thus avoid the IOException altogether.

这篇关于当SD卡满则抛出IOException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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