Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to obtain available free space on sdcard from android application?

Tags:

android

I am developing an android application where i need to determine the free space available on the sdcard. Can anyone give me some suggestion regarding this please.

thanks kaisar

like image 278
kaisar Avatar asked Nov 13 '10 05:11

kaisar


People also ask

How can I see what's taking up space on my SD card?

To see what those files are, go to Settings > Storage > Internal Storage. Whatever is taking up the most storage space will appear on top, and it'll show you how much storage it's taking up. If you want to view the pictures or files, you only have to tap on them.


1 Answers

Something like this should work:

File sdcard = Environment.getExternalStorageDirectory();
StatFs stat = new StatFs(sdcard.getAbsolutePath());
long available = stat.getAvailableBlocks() * (long) stat.getBlockSize();
like image 122
Erich Douglass Avatar answered Oct 11 '22 01:10

Erich Douglass