Reference

StorageStatsManager

StorageStatsManager is the Android system service (added in API 26) that reports how much storage apps and the device are using, broken into app code, user data, and cache. It is the supported way for a cleaner to read accurate per-app cache and data sizes.

Android developmentAndroid

StorageStatsManager

Also known as: storage stats android, app storage usage api, android storagestatsmanager

StorageStatsManager is the Android system service (added in API 26) that reports how much storage apps and the device are using, broken into app code, user data, and cache. It is the supported way for a cleaner to read accurate per-app cache and data sizes.

  • Introduced in Android 8.0 (API 26) in the android.app.usage package.
  • Reports app code, user data, and cache bytes, plus total and free space per volume.
  • Reading other apps' sizes requires the PACKAGE_USAGE_STATS usage-access permission.

What StorageStatsManager reports

StorageStatsManager (in android.app.usage, since Android 8.0 / API 26) returns a StorageStats object whose key fields are getAppBytes() (the APK and code), getDataBytes() (user data plus cache), and getCacheBytes() (just the cache portion). You query a specific app with queryStatsForPackage() or a whole UID with queryStatsForUid().

It also exposes device-wide figures: getTotalBytes() and getFreeBytes() for a storage volume, which is how an app shows total used versus free space. Volumes are identified by a storage UUID, with StorageManager.UUID_DEFAULT representing primary internal storage.

Permissions and access

Reading your own app's stats needs no special permission. Reading other apps' sizes requires the PACKAGE_USAGE_STATS special access, which the user grants through Settings > Apps > Special app access > Usage access (launched via ACTION_USAGE_ACCESS_SETTINGS). Without it, cross-app queries throw a SecurityException.

This replaced the old, deprecated PackageManager.getPackageSizeInfo() reflection hacks. StorageStatsManager is the official, stable API, so values match what the system Settings > Storage screen displays.

How a cleaner uses it

A storage cleaner like Cleanor uses getCacheBytes() per app to build the list of clearable junk and to total the space it can free, and it uses getFreeBytes() to show how much room is left on the device. These are the exact numbers users see in system Settings, so reporting stays trustworthy.

Because the API does not delete anything, the cleaner pairs it with the system's per-app Clear cache flow or its own cache directories to actually reclaim the space. Stats in, accurate sizes shown; clearing handled separately.

Related terms

Keep reading the reference.

Act on it

Guides and tools for this topic.