Reputation: 7264
I've got the "No space left on device" IOException when writing file. I wish to avoid it happens before writing. How should I do?
Thanks!
Upvotes: 1
Views: 307
Reputation: 3476
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;
Upvotes: 1