Skip to content

Commit

Permalink
fix: replace deprecated StatFs functions
Browse files Browse the repository at this point in the history
`getAvailableBytes` is available since api 18
while current cordova-android must be >=12.0.0, so minSdk 24
  • Loading branch information
ath0mas committed Aug 30, 2023
1 parent faba1bf commit 68856d5
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/android/DirectoryManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ public static long getFreeExternalStorageSpace() {
public static long getFreeSpaceInBytes(String path) {
try {
StatFs stat = new StatFs(path);
long blockSize = stat.getBlockSize();
long availableBlocks = stat.getAvailableBlocks();
return availableBlocks * blockSize;
return stat.getAvailableBytes();
} catch (IllegalArgumentException e) {
// The path was invalid. Just return 0 free bytes.
return 0;
Expand Down

0 comments on commit 68856d5

Please sign in to comment.