tags:

views:

163

answers:

1

Hi,

How do I check to see how much MB or GB is left on the android device ? I am using JAVA and android SDK 2.0.1.

Is there any system service that would expose something like this ?

Thank you

+2  A: 

Try that code

StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
long bytesAvailable = (long)stat.getBlockSize() *(long)stat.getBlockCount();
long megAvailable = bytesAvailable / 1048576;
System.out.println("Megs :"+megAvailable);

From there

Yaroslav Boichuk