Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Methods](https://developer.android.com/reference/android/app/usage/StorageStatsManager#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/app/usage/StorageStatsManager#inhmethods)

# StorageStatsManager

*** ** * ** ***


`
public


class
StorageStatsManager
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.app.usage.StorageStatsManager |

<br />

*** ** * ** ***

Access to detailed storage statistics. This provides a summary of how apps,
users, and external/shared storage is utilizing disk space.


Note: no permissions are required when calling these APIs for your own
package or UID. However, requesting details for any other package requires
the `android.Manifest.permission#PACKAGE_USAGE_STATS` permission, which
is a system-level permission that will not be granted to normal apps.
Declaring that permission expresses your intention to use this API and an end
user can then choose to grant this permission through the Settings
application.

<br />

## Summary

| ### Public methods ||
|---|---|
| ` long` | ` https://developer.android.com/reference/android/app/usage/StorageStatsManager#getFreeBytes(java.util.UUID)(https://developer.android.com/reference/java/util/UUID storageUuid) ` Return the free space on the requested storage volume. |
| ` long` | ` https://developer.android.com/reference/android/app/usage/StorageStatsManager#getTotalBytes(java.util.UUID)(https://developer.android.com/reference/java/util/UUID storageUuid) ` Return the total size of the underlying physical media that is hosting this storage volume. |
| ` https://developer.android.com/reference/android/app/usage/ExternalStorageStats` | ` https://developer.android.com/reference/android/app/usage/StorageStatsManager#queryExternalStatsForUser(java.util.UUID,%20android.os.UserHandle)(https://developer.android.com/reference/java/util/UUID storageUuid, https://developer.android.com/reference/android/os/UserHandle user) ` Return shared/external storage statistics for a specific `https://developer.android.com/reference/android/os/UserHandle` on the requested storage volume. |
| ` https://developer.android.com/reference/android/app/usage/StorageStats` | ` https://developer.android.com/reference/android/app/usage/StorageStatsManager#queryStatsForPackage(java.util.UUID,%20java.lang.String,%20android.os.UserHandle)(https://developer.android.com/reference/java/util/UUID storageUuid, https://developer.android.com/reference/java/lang/String packageName, https://developer.android.com/reference/android/os/UserHandle user) ` Return storage statistics for a specific package on the requested storage volume. |
| ` https://developer.android.com/reference/android/app/usage/StorageStats` | ` https://developer.android.com/reference/android/app/usage/StorageStatsManager#queryStatsForUid(java.util.UUID,%20int)(https://developer.android.com/reference/java/util/UUID storageUuid, int uid) ` Return storage statistics for a specific UID on the requested storage volume. |
| ` https://developer.android.com/reference/android/app/usage/StorageStats` | ` https://developer.android.com/reference/android/app/usage/StorageStatsManager#queryStatsForUser(java.util.UUID,%20android.os.UserHandle)(https://developer.android.com/reference/java/util/UUID storageUuid, https://developer.android.com/reference/android/os/UserHandle user) ` Return storage statistics for a specific `https://developer.android.com/reference/android/os/UserHandle` on the requested storage volume. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Public methods

### getFreeBytes

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public long getFreeBytes (UUID storageUuid)
```

Return the free space on the requested storage volume.


This value is best suited for visual display to end users, since it's
designed to reflect both unused space *and* and cached space that
could be reclaimed by the system.


Apps making logical decisions about disk space should always use
`https://developer.android.com/reference/android/os/storage/StorageManager#getAllocatableBytes(java.util.UUID)` instead of this value.


This method may take several seconds to complete, so it should
only be called from a worker thread.


Value is a non-negative number of bytes.

<br />

| Parameters ||
|---|---|
| `storageUuid` | `UUID`: the UUID of the storage volume you're interested in, such as `https://developer.android.com/reference/android/os/storage/StorageManager#UUID_DEFAULT`. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `long` | Value is a non-negative number of bytes. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` | when the storage device isn't present. |

### getTotalBytes

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public long getTotalBytes (UUID storageUuid)
```

Return the total size of the underlying physical media that is hosting
this storage volume.


This value is best suited for visual display to end users, since it's
designed to reflect the total storage size advertised in a retail
environment.


Apps making logical decisions about disk space should always use
`https://developer.android.com/reference/java/io/File#getTotalSpace()` instead of this value.


This method may take several seconds to complete, so it should
only be called from a worker thread.


Value is a non-negative number of bytes.

<br />

| Parameters ||
|---|---|
| `storageUuid` | `UUID`: the UUID of the storage volume you're interested in, such as `https://developer.android.com/reference/android/os/storage/StorageManager#UUID_DEFAULT`. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `long` | Value is a non-negative number of bytes. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` | when the storage device isn't present. |

### queryExternalStatsForUser

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ExternalStorageStats queryExternalStatsForUser (UUID storageUuid, 
                UserHandle user)
```

Return shared/external storage statistics for a specific
`https://developer.android.com/reference/android/os/UserHandle` on the requested storage volume.


Note: this API requires the
`android.Manifest.permission#PACKAGE_USAGE_STATS` permission, which
is a system-level permission that will not be granted to normal apps.
Declaring that permission expresses your intention to use this API and an
end user can then choose to grant this permission through the Settings
application.
.   
This method may take several seconds to complete, so it should only be called from a worker thread.

<br />

<br />

| Parameters ||
|---|---|
| `storageUuid` | `UUID`: the UUID of the storage volume you're interested in, such as `https://developer.android.com/reference/android/os/storage/StorageManager#UUID_DEFAULT`. This value cannot be `null`. <br /> |
| `user` | `UserHandle`: This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/usage/ExternalStorageStats` | This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` | when the storage device isn't present. |

**See also:**

- `https://developer.android.com/reference/android/os/Process#myUserHandle()`

### queryStatsForPackage

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StorageStats queryStatsForPackage (UUID storageUuid, 
                String packageName, 
                UserHandle user)
```

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


Note: no permissions are required when calling this API for your own
package. However, requesting details for any other package requires the
`android.Manifest.permission#PACKAGE_USAGE_STATS` permission, which
is a system-level permission that will not be granted to normal apps.
Declaring that permission expresses your intention to use this API and an
end user can then choose to grant this permission through the Settings
application.


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
`https://developer.android.com/reference/android/app/usage/StorageStatsManager#queryStatsForUid(java.util.UUID,%20int)`, which is typically faster.
.   
This method may take several seconds to complete, so it should only be called from a worker thread.

<br />

<br />

| Parameters ||
|---|---|
| `storageUuid` | `UUID`: the UUID of the storage volume you're interested in, such as `https://developer.android.com/reference/android/os/storage/StorageManager#UUID_DEFAULT`. This value cannot be `null`. <br /> |
| `packageName` | `String`: the package name you're interested in. This value cannot be `null`. <br /> |
| `user` | `UserHandle`: the user you're interested in. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/usage/StorageStats` | This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/android/content/pm/PackageManager.NameNotFoundException` | when the requested package name isn't installed for the requested user. |
| `https://developer.android.com/reference/java/io/IOException` | when the storage device isn't present. |

**See also:**

- `https://developer.android.com/reference/android/content/pm/ApplicationInfo#storageUuid`
- `https://developer.android.com/reference/android/content/pm/PackageInfo#packageName`

### queryStatsForUid

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StorageStats queryStatsForUid (UUID storageUuid, 
                int uid)
```

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


Note: no permissions are required when calling this API for your own UID.
However, requesting details for any other UID requires the
`android.Manifest.permission#PACKAGE_USAGE_STATS` permission, which
is a system-level permission that will not be granted to normal apps.
Declaring that permission expresses your intention to use this API and an
end user can then choose to grant this permission through the Settings
application.
.   
This method may take several seconds to complete, so it should only be called from a worker thread.

<br />

<br />

| Parameters ||
|---|---|
| `storageUuid` | `UUID`: the UUID of the storage volume you're interested in, such as `https://developer.android.com/reference/android/os/storage/StorageManager#UUID_DEFAULT`. This value cannot be `null`. <br /> |
| `uid` | `int`: the UID you're interested in. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/usage/StorageStats` | This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` | when the storage device isn't present. |

**See also:**

- `https://developer.android.com/reference/android/content/pm/ApplicationInfo#storageUuid`
- `https://developer.android.com/reference/android/content/pm/ApplicationInfo#uid`

### queryStatsForUser

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public StorageStats queryStatsForUser (UUID storageUuid, 
                UserHandle user)
```

Return storage statistics for a specific `https://developer.android.com/reference/android/os/UserHandle` on the
requested storage volume.


Note: this API requires the
`android.Manifest.permission#PACKAGE_USAGE_STATS` permission, which
is a system-level permission that will not be granted to normal apps.
Declaring that permission expresses your intention to use this API and an
end user can then choose to grant this permission through the Settings
application.
.   
This method may take several seconds to complete, so it should only be called from a worker thread.

<br />

<br />

| Parameters ||
|---|---|
| `storageUuid` | `UUID`: the UUID of the storage volume you're interested in, such as `https://developer.android.com/reference/android/os/storage/StorageManager#UUID_DEFAULT`. This value cannot be `null`. <br /> |
| `user` | `UserHandle`: the user you're interested in. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/usage/StorageStats` | This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` | when the storage device isn't present. |

**See also:**

- `https://developer.android.com/reference/android/os/Process#myUserHandle()`