diff options
author | Martin Fietz <Martin.Fietz@gmail.com> | 2015-12-31 14:17:12 +0100 |
---|---|---|
committer | Martin Fietz <Martin.Fietz@gmail.com> | 2015-12-31 14:17:12 +0100 |
commit | b793866ed407933b17cc4fb2dc43ec2d6df3722b (patch) | |
tree | 6b08d72f4727d1a44949ae68bb3f046f34e4ffc9 /core | |
parent | d18efcc3b178a6ae35344a90eed09b7b1ab51689 (diff) | |
download | AntennaPod-b793866ed407933b17cc4fb2dc43ec2d6df3722b.zip |
Show free space for current choice
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/util/StorageUtils.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/StorageUtils.java b/core/src/main/java/de/danoeh/antennapod/core/util/StorageUtils.java index 248f2bf32..d64148715 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/StorageUtils.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/StorageUtils.java @@ -51,8 +51,19 @@ public class StorageUtils { * Get the number of free bytes that are available on the external storage. */ public static long getFreeSpaceAvailable() { - StatFs stat = new StatFs(UserPreferences.getDataFolder( - null).getAbsolutePath()); + File dataFolder = UserPreferences.getDataFolder(null); + if (dataFolder != null) { + return getFreeSpaceAvailable(dataFolder.getAbsolutePath()); + } else { + return 0; + } + } + + /** + * Get the number of free bytes that are available on the external storage. + */ + public static long getFreeSpaceAvailable(String path) { + StatFs stat = new StatFs(path); long availableBlocks; long blockSize; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { |