0

i want to get available space in SD card and the internal memory

i used following code to get available space in internal memory

StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
        double sdAvailSize = (double) stat.getAvailableBlocks()
                * (double) stat.getBlockSize();
        // One binary gigabyte equals 1,073,741,824 bytes.
        double gigaAvailable = sdAvailSize / 1073741824;

But is thr anyway that i can get available space in SD card , i know for sure that i cannot use SD card on Kit-kat , but if i am using jelly beans , is thr anyway that i can access to SD card available space

Device 4.1.2

Mr.G
  • 1,275
  • 1
  • 18
  • 48

1 Answers1

1

There is no way to know the path to external SD card on pre-KitKat devices, the API getExternalFilesDirs() is available only in KitKat. You can use various hacks to guess the SD card path, for example reading /proc/mounts, as described in this answer

Community
  • 1
  • 1
pelya
  • 4,326
  • 2
  • 24
  • 23