tags:

views:

52

answers:

2

Hi folks,

How do you check if the SD card is full or not so that your application can decide if it can continue to do its job i.e. write to external storage or notify the user that storage has run out of space.

Cheers

A: 

Hi Namratha. I think you can use this statement to do with your problem. this cant check whether or no enough capacity of sdcard. if(android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)){ //to do something in here }

Hoang Anh Song
Hi Hoang,Thanks. That will only tell me whether the media is mounted with read/write access. I want to know whether the media is full or not. Any idea?
Namratha
+1  A: 

use StatFs and pass the path of the external storage directory to the constructor and you can call functions such as getAvailableBlocks() and getBlockSize() on the StatFs object.

Namratha