Skip to content

Most visited

Recently visited

navigation

StorageStatsManager

public class StorageStatsManager
extends Object

java.lang.Object
   ↳ android.app.usage.StorageStatsManager


Provides access to detailed storage statistics.

Note: this API requires the permission android.permission.PACKAGE_USAGE_STATS, which is a system-level permission that will not be granted to normal apps. However, declaring the permission expresses your intention to use this API and an end user can then choose to grant this permission through the Settings application.

Summary

Public methods

long getFreeBytes(String volumeUuid)

Return the free space on the requested storage volume.

long getTotalBytes(String volumeUuid)

Return the total space on the requested storage volume.

ExternalStorageStats queryExternalStatsForUser(String volumeUuid, UserHandle user)

Return shared/external storage statistics for a specific UserHandle on the requested storage volume.

StorageStats queryStatsForPackage(String volumeUuid, String packageName, UserHandle user)

Return storage statistics for a specific package on the requested storage volume.

StorageStats queryStatsForUid(String volumeUuid, int uid)

Return storage statistics for a specific UID on the requested storage volume.

StorageStats queryStatsForUser(String volumeUuid, UserHandle user)

Return storage statistics for a specific UserHandle on the requested storage volume.

Inherited methods

From class java.lang.Object

Public methods

getFreeBytes

long getFreeBytes (String volumeUuid)

Return the free space on the requested storage volume.

The free space is equivalent to getFreeSpace() plus the size of any cached data that can be automatically deleted by the system as additional space is needed.

This method may take several seconds to calculate the requested values, so it should only be called from a worker thread.

Parameters
volumeUuid String: the UUID of the storage volume you're interested in, or null to specify the default internal storage.
Returns
long

getTotalBytes

long getTotalBytes (String volumeUuid)

Return the total space on the requested storage volume.

To reduce end user confusion, this value is the total storage size advertised in a retail environment, which is typically larger than the actual writable partition total size.

This method may take several seconds to calculate the requested values, so it should only be called from a worker thread.

Parameters
volumeUuid String: the UUID of the storage volume you're interested in, or null to specify the default internal storage.
Returns
long

queryExternalStatsForUser

ExternalStorageStats queryExternalStatsForUser (String volumeUuid, 
                UserHandle user)

Return shared/external storage statistics for a specific UserHandle on the requested storage volume.

This method may take several seconds to calculate the requested values, so it should only be called from a worker thread.

Parameters
volumeUuid String: the UUID of the storage volume you're interested in, or null to specify the default internal storage.
user UserHandle
Returns
ExternalStorageStats

See also:

queryStatsForPackage

StorageStats queryStatsForPackage (String volumeUuid, 
                String packageName, 
                UserHandle user)

Return storage statistics for a specific package on the requested storage volume.

This method may take several seconds to calculate the requested values, so it should only be called from a worker thread.

Note: if the requested package uses the android:sharedUserId manifest feature, this call will be forced into a slower manual calculation path. If possible, consider always using queryStatsForUid(String, int), which is typically faster.

Parameters
volumeUuid String: the UUID of the storage volume you're interested in, or null to specify the default internal storage.
packageName String: the package name you're interested in.
user UserHandle: the user you're interested in.
Returns
StorageStats

See also:

queryStatsForUid

StorageStats queryStatsForUid (String volumeUuid, 
                int uid)

Return storage statistics for a specific UID on the requested storage volume.

This method may take several seconds to calculate the requested values, so it should only be called from a worker thread.

Parameters
volumeUuid String: the UUID of the storage volume you're interested in, or null to specify the default internal storage.
uid int: the UID you're interested in.
Returns
StorageStats

See also:

queryStatsForUser

StorageStats queryStatsForUser (String volumeUuid, 
                UserHandle user)

Return storage statistics for a specific UserHandle on the requested storage volume.

This method may take several seconds to calculate the requested values, so it should only be called from a worker thread.

Parameters
volumeUuid String: the UUID of the storage volume you're interested in, or null to specify the default internal storage.
user UserHandle: the user you're interested in.
Returns
StorageStats

See also:

This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.