0

I am saving file on "getFilesDir().getAbsolutePath()" which is app private folder. I want to know how much free space available before save to that location.

If there is not enough space available then force user to delete some files to free up space.

How could I determine how much free space available?

Rohan Patel
  • 1,758
  • 2
  • 21
  • 38

1 Answers1

1
StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
long bytesAvailable = (long)stat.getBlockSize() *(long)stat.getBlockCount();
long megAvailable = bytesAvailable / 1048576;
System.out.println("Megs :"+megAvailable);

Source Link

coder_baba
  • 447
  • 3
  • 21
  • By using this code chunk, You can calculate remaining size in your device and doing some modification, you can count folder available space – coder_baba May 23 '17 at 13:22