Wednesday, 29 April 2015

Get Available Space on sdcard if sdcard available


/**
  * do this only *after* you have checked external storage state:
  **/

   File extdir              =  Environment.getExternalStorageDirectory();
   StatFs stats            =  new StatFs(extdir.getAbsolutePath());
   int availableBytes =  stats.getAvailableBlocks() * stats.getBlockSize();

   Log.d("Available Space :", String.valueOf(availableBytes) + "Bytes");  


/**
 * Check SDCard Available Or Not
 **/

Boolean isSDPresent = android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);

if(isSDPresent)
{
  // yes SD-card is present
}
else
{
 // No Sdcard Is Present
}

No comments:

Post a Comment