First question, when an app is on a device, what is the max storage that it can take up. I have an app that writes a lot of files and at some point I can no longer save files to the device, but if I look on the device there is plenty of space available (3+ GB), so does Xamarin or Android tell the app you only have x amount of space to store data? What is x and is it configurable? Second question, how can I programmatically determine in my app how much of that space is available to let the user know what is free and how close they are to the max? Thanks!
Asked
Active
Viewed 254 times
1 Answers
1
There are minimum sizes of the data partition defined by Google:
Device implementations MUST have at least 512MB of non-volatile storage available for user data. That is, the /data partition MUST be at least 512MB.
For API details see this SO: https://stackoverflow.com/a/9198511/4984832
OEMs apply what the maximum of the data partition and you can use StatFs
to see what is currently available at runtime:
using (var dataPath = Android.OS.Environment.DataDirectory)
using (var stat = new StatFs(dataPath.AbsolutePath))
{
Log.Debug(TAG, $" Bytes: {stat.TotalBytes} : {stat.AvailableBytes}");
Log.Debug(TAG, $"Blocks: {stat.BlockCountLong} : {stat.AvailableBlocksLong}");
}
Example output:
[SushiDrive] Bytes: 2080194560 : 1900834816
[SushiDrive] Blocks: 507860 : 464071
Re: https://developer.android.com/reference/android/os/StatFs.html

SushiHangover
- 73,120
- 10
- 106
- 165