Show free space for current choice
This commit is contained in:
parent
d18efcc3b1
commit
b793866ed4
|
@ -711,7 +711,7 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
|
|||
} else {
|
||||
choices[i] = path;
|
||||
}
|
||||
long bytes = StorageUtils.getFreeSpaceAvailable();
|
||||
long bytes = StorageUtils.getFreeSpaceAvailable(path);
|
||||
String freeSpace = String.format(context.getString(R.string.free_space_label),
|
||||
Converter.byteToString(bytes));
|
||||
choices[i] = Html.fromHtml("<html><small>" + choices[i]
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue