开发者

How to know the sdcard has enough free size to write in on Android?

I've got th开发者_如何学Goe "No space left on device" IOException when writing file. I wish to avoid it happens before writing. How should I do?

Thanks!


from: http://groups.google.com/group/android-developers/browse_thread/thread/ecede996463a4058

StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
long bytesAvailable = (long)stat.getBlockSize() * (long)stat.getBlockCount();
long megAvailable = bytesAvailable / 1048576;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜