Unverified Commit e484701e authored by Mehdi Achour's avatar Mehdi Achour Committed by GitHub

fix: make getTotalDiskCapacity() and getFreeDiskStorage() available < SDK18 (#319)

parent 626d318f
......@@ -2,6 +2,10 @@
### Next
### 0.15.1
* Fix Android compatibility for `getFreeDiskStorage` and `getTotalDiskCapacity` (https://github.com/rebeccahughes/react-native-device-info/pull/319)
### 0.15.0
* Add `getFontScale` (https://github.com/rebeccahughes/react-native-device-info/pull/278)
......
......@@ -127,15 +127,15 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
}
@ReactMethod
public long getTotalDiskCapacity() {
public int getTotalDiskCapacity() {
StatFs root = new StatFs(Environment.getRootDirectory().getAbsolutePath());
return root.getBlockCountLong() * root.getBlockSizeLong();
return root.getBlockCount() * root.getBlockSize();
}
@ReactMethod
public long getFreeDiskStorage() {
public int getFreeDiskStorage() {
StatFs external = new StatFs(Environment.getExternalStorageDirectory().getAbsolutePath());
return external.getAvailableBlocksLong() * external.getBlockSizeLong();
return external.getAvailableBlocks() * external.getBlockSize();
}
@Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment