I'm making an android app and want to display to the user how much space I am taking up on their phone with data.
I currently am getting the size of the database file, and package application file, and adding them together but it is no where near the statistics shown in the android app settings.
I'm wondering if there is a way to get the data shown in the settings app:
as my current approach:
long dbsize = DAL.Repository.getDBSizeinKB(); // is 18 MB
ApplicationInfo appinfo = a.PackageManager.GetApplicationInfo(a.ApplicationInfo.PackageName, 0);
long appsize = new FileInfo(appinfo.SourceDir).Length / 1000; // 4MB
string spaceUsed = "";
long totalsize = dbsize + appsize;
spaceUsed = totalsize.ToString() + " kB";
if (totalsize >= 1000)
spaceUsed = (totalsize / 1000).ToString() + " MB";
sizeView.Text = "Space used: " + spaceUsed; // 22MB
is off.