Any idea of how I can read/get the real amount of free space on a sd card? I'm running on Android 4.3. I have tried all possible things to read it correctly, however I'm getting something a bit over twice the real free space.
Now I've tried the classic
StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
availableSpace = (long) stat.getAvailableBlocks() * (long) stat.getBlockSize();
using the API 18 getAvailableBlocksLong
and other getBlockSizeLong
and still the same result.
The only thing that works (but it's not what I need) is the shell command df. I also tried the get usable free space functions with the same result. And this thing doesn't happen on my device only, but on all devices that I try the code.