2

There are three types of memory in the android:

+Internal Memory (DONE)

+SdCard (DONE)

+External Sd Card (external memory card - external storage (FLASH)): How to get total size of it's and How to identify the external_sdcard directory in android?? Hope soon to get answers :)

hungtdo
  • 661
  • 7
  • 15

2 Answers2

1
StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
long bytesCount = (long)stat.getBlockSize() * (long)stat.getBlockCount();
return bytesCount;
Roman Black
  • 3,501
  • 1
  • 22
  • 31
0

If Environment.getExternalStorage... is not working, use:

StatFs statFs = new StatFs(System.getenv("SECONDARY_STORAGE"));
float total_space = ((float)statFs.getBlockCount() * statFs.getBlockSize()) / 1048576;

// This will give in mega bytes. 

Enjoy. Hope this is helpful.

// For internal storage use this> System.getenv("EXTERNAL_STORAGE")