Skip to content

Instantly share code, notes, and snippets.

@Richie97
Created November 16, 2016 19:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Richie97/7e66a39663608631a55fe323a3416c4a to your computer and use it in GitHub Desktop.
Save Richie97/7e66a39663608631a55fe323a3416c4a to your computer and use it in GitHub Desktop.
Getting Free Space on External Storage
public long getFreeMemory() {
File externalStorageDir = Environment.getExternalStorageDirectory();
StatFs statFs = new StatFs(externalStorageDir.getAbsolutePath());
long blocks = statFs.getAvailableBlocks();
long free = (blocks * statFs.getBlockSize()) / 1024 / 1024;
return free;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment