Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect total diskspace #6

Open
findsarfaraz opened this issue Nov 14, 2021 · 1 comment
Open

Incorrect total diskspace #6

findsarfaraz opened this issue Nov 14, 2021 · 1 comment

Comments

@findsarfaraz
Copy link

findsarfaraz commented Nov 14, 2021

I am not sure if anyone else is facing this issue. I am using this package to get to make file manager. However, My 128GB phone is showing only 97 GB.

Mentioned below is function I am using for printing disksize;

Future initDiskSpace() async {
double diskSpace = 0;

double _diskSpace = 0;
Map<Directory, double> _directorySpace = {};

// diskSpace = await DiskSpace.getFreeDiskSpace;

List<Directory> directories = [];
Map<Directory, double> directorySpace = {};

if (Platform.isIOS) {
  directories = [await getApplicationDocumentsDirectory()];
} else if (Platform.isAndroid) {
  directories =
      await getExternalStorageDirectories(type: StorageDirectory.dcim).then(
    (list) async => list ?? [await getApplicationDocumentsDirectory()],
  );
}

for (var directory in directories) {
  var _diskSpace = await DiskSpace.getTotalDiskSpace;
  directorySpace.addEntries([MapEntry(directory, _diskSpace!)]);
}

// if (!mounted) return;

print(_diskSpace);
print(directorySpace);

}

@h3x4d3c1m4l
Copy link

h3x4d3c1m4l commented Dec 30, 2021

Hi @findsarfaraz, I'm not the author of this package but by accident I was reading through the issues and I might be able to answer your question.

Android devices use disk partitions. So while a phone that is marketed as 128 GB probably actually has a 128 GB storage chip, its space is divided between a "System" partition and a "Data" partition.

This System partition contains the Android OS. Depending on the vendor, the system image can get quite large (e.g. Samsung Galaxy S20 images are 5 GB already when compressed).

What you are seeing should be the size of the Data partition which is where your downloaded apps go, any data your apps store on your phone, as well as your personal data like photos you might have taken, file downloads, etc.

Unfortunately I'm not aware of any API features that allow you to get the "marketed total disk space" of a device.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants