1

I am a beginner in android. I want to know how to programmatically find the path to Internal SD card, External SD card, Internal Phone Storage and Personal Data in android. I also want to know how to find their memory size (Used and Free Space).
If it is possible please send information. Otherwise send Reason. Please reply your answers and comments are valuable me. Thanks.

Bala
  • 445
  • 5
  • 11
  • 26

1 Answers1

1
 File sdCardDirectory = Environment.getExternalStorageDirectory(); 

 This is to find sdcard path

 File path = Environment.getDataDirectory();
 StatFs stat = new StatFs(path.getPath()); 
 long blockSize = stat.getBlockSize(); 
 long availableBlocks = stat.getAvailableBlocks(); 
 return Formatter.formatFileSize(this, availableBlocks * blockSize); 

 This is to find Internal Phone Storage
Kalai Selvan.G
  • 482
  • 3
  • 10
  • 22
  • Thanks. But how to find others path and memory size. – Bala Jun 12 '12 at 08:28
  • Selvan.. Thanks it's working fine. For example My Mobile is used to internal sd card, and external sd card. How to find path of Internal Sd Card. – Bala Jun 12 '12 at 10:00
  • What's the reason. Why can't find Internal SD Card path. – Bala Jun 12 '12 at 10:46
  • http://stackoverflow.com/questions/3591494/writing-to-internal-sd-card-on-android?rq=1 see this – Kalai Selvan.G Jun 12 '12 at 10:54
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/12434/discussion-between-kalai-selvan-g-and-bala) – Kalai Selvan.G Jun 12 '12 at 11:02
  • There is no official way to get the path of the sd card. It depends on the manufacturer what Environment.getExternalStorageDirectory returns. See http://stackoverflow.com/questions/5694933/find-an-external-sd-card-location – aleb May 17 '13 at 16:45