Added in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Nested Classes](https://developer.android.com/reference/android/os/storage/StorageManager#nestedclasses) \| [Constants](https://developer.android.com/reference/android/os/storage/StorageManager#constants) \| [Fields](https://developer.android.com/reference/android/os/storage/StorageManager#lfields) \| [Methods](https://developer.android.com/reference/android/os/storage/StorageManager#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/os/storage/StorageManager#inhmethods)

# StorageManager

*** ** * ** ***

` public class StorageManager `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.os.storage.StorageManager |

<br />

*** ** * ** ***

StorageManager is the interface to the systems storage service. The storage manager handles storage-related items such as Opaque Binary Blobs (OBBs).

OBBs contain a filesystem that maybe be encrypted on disk and mounted on-demand from an application. OBBs are a good way of providing large amounts of binary assets without packaging them into APKs as they may be multiple gigabytes in size. However, due to their size, they're most likely stored in a shared storage pool accessible from all programs. The system does not guarantee the security of the OBB file itself: if any program modifies the OBB, there is no guarantee that a read from that OBB will produce the expected output.

## Summary

| ### Nested classes ||
|---|---|
| ` class` | `https://developer.android.com/reference/android/os/storage/StorageManager.StorageVolumeCallback` Callback that delivers `https://developer.android.com/reference/android/os/storage/StorageVolume` related events. |

| ### Constants ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/os/storage/StorageManager#ACTION_CLEAR_APP_CACHE` Activity Action: Allows the user to free up space by clearing app external cache directories. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/os/storage/StorageManager#ACTION_MANAGE_STORAGE` Activity Action: Allows the user to manage their storage. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/os/storage/StorageManager#EXTRA_REQUESTED_BYTES` Extra used to indicate the total size (in bytes) that an application is interested in allocating. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/os/storage/StorageManager#EXTRA_UUID` Extra `https://developer.android.com/reference/java/util/UUID` used to indicate the storage volume where an application is interested in allocating or managing disk space. |

| ### Fields ||
|---|---|
| ` public static final https://developer.android.com/reference/java/util/UUID` | `https://developer.android.com/reference/android/os/storage/StorageManager#UUID_DEFAULT` UUID representing the default internal storage of this device which provides `https://developer.android.com/reference/android/os/Environment#getDataDirectory()`. |

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/os/storage/StorageManager#allocateBytes(java.io.FileDescriptor,%20long)(https://developer.android.com/reference/java/io/FileDescriptor fd, long bytes) ` Allocate the requested number of bytes for your application to use in the given open file. |
| ` void` | ` https://developer.android.com/reference/android/os/storage/StorageManager#allocateBytes(java.util.UUID,%20long)(https://developer.android.com/reference/java/util/UUID storageUuid, long bytes) ` Allocate the requested number of bytes for your application to use on the given storage volume. |
| ` long` | ` https://developer.android.com/reference/android/os/storage/StorageManager#getAllocatableBytes(java.util.UUID)(https://developer.android.com/reference/java/util/UUID storageUuid) ` Return the maximum number of new bytes that your app can allocate for itself on the given storage volume. |
| ` long` | ` https://developer.android.com/reference/android/os/storage/StorageManager#getCacheQuotaBytes(java.util.UUID)(https://developer.android.com/reference/java/util/UUID storageUuid) ` Return quota size in bytes for all cached data belonging to the calling app on the given storage volume. |
| ` long` | ` https://developer.android.com/reference/android/os/storage/StorageManager#getCacheSizeBytes(java.util.UUID)(https://developer.android.com/reference/java/util/UUID storageUuid) ` Return total size in bytes of all cached data belonging to the calling app on the given storage volume. |
| ` https://developer.android.com/reference/android/app/PendingIntent` | ` https://developer.android.com/reference/android/os/storage/StorageManager#getManageSpaceActivityIntent(java.lang.String,%20int)(https://developer.android.com/reference/java/lang/String packageName, int requestCode) ` Returns a `https://developer.android.com/reference/android/app/PendingIntent` that can be used by Apps with `https://developer.android.com/reference/android/Manifest.permission#MANAGE_EXTERNAL_STORAGE` permission to launch the manageSpaceActivity for any App that implements it, irrespective of its exported status. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/os/storage/StorageManager#getMountedObbPath(java.lang.String)(https://developer.android.com/reference/java/lang/String rawPath) ` Check the mounted path of an Opaque Binary Blob (OBB) file. |
| ` https://developer.android.com/reference/android/os/storage/StorageVolume` | ` https://developer.android.com/reference/android/os/storage/StorageManager#getPrimaryStorageVolume()() ` Return the primary shared/external storage volume available to the current user. |
| ` https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/os/storage/StorageVolume>` | ` https://developer.android.com/reference/android/os/storage/StorageManager#getRecentStorageVolumes()() ` Return the list of shared/external storage volumes both currently and recently available to the calling user. |
| ` https://developer.android.com/reference/android/os/storage/StorageVolume` | ` https://developer.android.com/reference/android/os/storage/StorageManager#getStorageVolume(java.io.File)(https://developer.android.com/reference/java/io/File file) ` Return the `https://developer.android.com/reference/android/os/storage/StorageVolume` that contains the given file, or `null` if none. |
| ` https://developer.android.com/reference/android/os/storage/StorageVolume` | ` https://developer.android.com/reference/android/os/storage/StorageManager#getStorageVolume(android.net.Uri)(https://developer.android.com/reference/android/net/Uri uri) ` Return the `https://developer.android.com/reference/android/os/storage/StorageVolume` that contains the given `https://developer.android.com/reference/android/provider/MediaStore` item. |
| ` https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/os/storage/StorageVolume>` | ` https://developer.android.com/reference/android/os/storage/StorageManager#getStorageVolumes()() ` Return the list of shared/external storage volumes currently available to the calling user. |
| ` https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/os/storage/StorageVolume>` | ` https://developer.android.com/reference/android/os/storage/StorageManager#getStorageVolumesIncludingSharedProfiles()() ` Return the list of shared/external storage volumes currently available to the calling user and the user it shares media with. |
| ` https://developer.android.com/reference/java/util/UUID` | ` https://developer.android.com/reference/android/os/storage/StorageManager#getUuidForPath(java.io.File)(https://developer.android.com/reference/java/io/File path) ` Return a UUID identifying the storage volume that hosts the given filesystem path. |
| ` boolean` | ` https://developer.android.com/reference/android/os/storage/StorageManager#isAllocationSupported(java.io.FileDescriptor)(https://developer.android.com/reference/java/io/FileDescriptor fd) ` Test if the given file descriptor supports allocation of disk space using `https://developer.android.com/reference/android/os/storage/StorageManager#allocateBytes(java.io.FileDescriptor,%20long)`. |
| ` boolean` | ` https://developer.android.com/reference/android/os/storage/StorageManager#isCacheBehaviorGroup(java.io.File)(https://developer.android.com/reference/java/io/File path) ` Read the current value set by `https://developer.android.com/reference/android/os/storage/StorageManager#setCacheBehaviorGroup(java.io.File,%20boolean)`. |
| ` boolean` | ` https://developer.android.com/reference/android/os/storage/StorageManager#isCacheBehaviorTombstone(java.io.File)(https://developer.android.com/reference/java/io/File path) ` Read the current value set by `https://developer.android.com/reference/android/os/storage/StorageManager#setCacheBehaviorTombstone(java.io.File,%20boolean)`. |
| ` boolean` | ` https://developer.android.com/reference/android/os/storage/StorageManager#isCheckpointSupported()() ` Check whether the device supports filesystem checkpoint. |
| ` boolean` | ` https://developer.android.com/reference/android/os/storage/StorageManager#isEncrypted(java.io.File)(https://developer.android.com/reference/java/io/File file) ` Return if data stored at or under the given path will be encrypted while at rest. |
| ` boolean` | ` https://developer.android.com/reference/android/os/storage/StorageManager#isObbMounted(java.lang.String)(https://developer.android.com/reference/java/lang/String rawPath) ` Check whether an Opaque Binary Blob (OBB) is mounted or not. |
| ` boolean` | ` https://developer.android.com/reference/android/os/storage/StorageManager#mountObb(java.lang.String,%20java.lang.String,%20android.os.storage.OnObbStateChangeListener)(https://developer.android.com/reference/java/lang/String rawPath, https://developer.android.com/reference/java/lang/String key, https://developer.android.com/reference/android/os/storage/OnObbStateChangeListener listener) ` Mount an Opaque Binary Blob (OBB) file. |
| ` https://developer.android.com/reference/android/os/ParcelFileDescriptor` | ` https://developer.android.com/reference/android/os/storage/StorageManager#openProxyFileDescriptor(int,%20android.os.ProxyFileDescriptorCallback,%20android.os.Handler)(int mode, https://developer.android.com/reference/android/os/ProxyFileDescriptorCallback callback, https://developer.android.com/reference/android/os/Handler handler) ` Opens a seekable `https://developer.android.com/reference/android/os/ParcelFileDescriptor` that proxies all low-level I/O requests back to the given `https://developer.android.com/reference/android/os/ProxyFileDescriptorCallback`. |
| ` void` | ` https://developer.android.com/reference/android/os/storage/StorageManager#registerStorageVolumeCallback(java.util.concurrent.Executor,%20android.os.storage.StorageManager.StorageVolumeCallback)(https://developer.android.com/reference/java/util/concurrent/Executor executor, https://developer.android.com/reference/android/os/storage/StorageManager.StorageVolumeCallback callback) ` Registers the given callback to listen for `https://developer.android.com/reference/android/os/storage/StorageVolume` changes. |
| ` void` | ` https://developer.android.com/reference/android/os/storage/StorageManager#setCacheBehaviorGroup(java.io.File,%20boolean)(https://developer.android.com/reference/java/io/File path, boolean group) ` Enable or disable special cache behavior that treats this directory and its contents as an entire group. |
| ` void` | ` https://developer.android.com/reference/android/os/storage/StorageManager#setCacheBehaviorTombstone(java.io.File,%20boolean)(https://developer.android.com/reference/java/io/File path, boolean tombstone) ` Enable or disable special cache behavior that leaves deleted cache files intact as tombstones. |
| ` boolean` | ` https://developer.android.com/reference/android/os/storage/StorageManager#unmountObb(java.lang.String,%20boolean,%20android.os.storage.OnObbStateChangeListener)(https://developer.android.com/reference/java/lang/String rawPath, boolean force, https://developer.android.com/reference/android/os/storage/OnObbStateChangeListener listener) ` Unmount an Opaque Binary Blob (OBB) file asynchronously. |
| ` void` | ` https://developer.android.com/reference/android/os/storage/StorageManager#unregisterStorageVolumeCallback(android.os.storage.StorageManager.StorageVolumeCallback)(https://developer.android.com/reference/android/os/storage/StorageManager.StorageVolumeCallback callback) ` Unregisters the given callback from listening for `https://developer.android.com/reference/android/os/storage/StorageVolume` changes. |

### 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*.

## Constants

### ACTION_CLEAR_APP_CACHE

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

```
public static final String ACTION_CLEAR_APP_CACHE
```

Activity Action: Allows the user to free up space by clearing app external cache directories. The intent doesn't automatically clear cache, but shows a dialog and lets the user decide.

This intent should be launched using `https://developer.android.com/reference/android/app/Activity#startActivityForResult(android.content.Intent,%20int)` so that the user knows which app is requesting to clear cache. The returned result will be: `https://developer.android.com/reference/android/app/Activity#RESULT_OK` if the activity was launched and all cache was cleared, `https://developer.android.com/reference/android/system/OsConstants#EIO` if an error occurred while clearing the cache or `https://developer.android.com/reference/android/app/Activity#RESULT_CANCELED` otherwise.   

Requires `https://developer.android.com/reference/android/Manifest.permission#MANAGE_EXTERNAL_STORAGE`

<br />

Constant Value: "android.os.storage.action.CLEAR_APP_CACHE"

### ACTION_MANAGE_STORAGE

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

```
public static final String ACTION_MANAGE_STORAGE
```

Activity Action: Allows the user to manage their storage. This activity provides the ability to free up space on the device by deleting data such as apps.

If the sending application has a specific storage device or allocation size in mind, they can optionally define `https://developer.android.com/reference/android/os/storage/StorageManager#EXTRA_UUID` or `https://developer.android.com/reference/android/os/storage/StorageManager#EXTRA_REQUESTED_BYTES`, respectively.

This intent should be launched using `https://developer.android.com/reference/android/app/Activity#startActivityForResult(android.content.Intent,%20int)` so that the user knows which app is requesting the storage space. The returned result will be `https://developer.android.com/reference/android/app/Activity#RESULT_OK` if the requested space was made available, or `https://developer.android.com/reference/android/app/Activity#RESULT_CANCELED` otherwise.

<br />

Constant Value: "android.os.storage.action.MANAGE_STORAGE"

### EXTRA_REQUESTED_BYTES

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

```
public static final String EXTRA_REQUESTED_BYTES
```

Extra used to indicate the total size (in bytes) that an application is interested in allocating.

When defined, the management UI will help guide the user to free up enough disk space to reach this requested value.

<br />

**See also:**

- `https://developer.android.com/reference/android/os/storage/StorageManager#ACTION_MANAGE_STORAGE`

Constant Value: "android.os.storage.extra.REQUESTED_BYTES"

### EXTRA_UUID

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

```
public static final String EXTRA_UUID
```

Extra `https://developer.android.com/reference/java/util/UUID` used to indicate the storage volume where an application is interested in allocating or managing disk space.

<br />

**See also:**

- `https://developer.android.com/reference/android/os/storage/StorageManager#ACTION_MANAGE_STORAGE`
- `https://developer.android.com/reference/android/os/storage/StorageManager#UUID_DEFAULT`
- `https://developer.android.com/reference/android/os/storage/StorageManager#getUuidForPath(java.io.File)`
- `https://developer.android.com/reference/android/content/Intent#putExtra(java.lang.String,%20java.io.Serializable)`

Constant Value: "android.os.storage.extra.UUID"

## Fields

### UUID_DEFAULT

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

```
public static final UUID UUID_DEFAULT
```

UUID representing the default internal storage of this device which provides `https://developer.android.com/reference/android/os/Environment#getDataDirectory()`.

This value is constant across all devices and it will never change, and thus it cannot be used to uniquely identify a particular physical device.

<br />

**See also:**

- `https://developer.android.com/reference/android/os/storage/StorageManager#getUuidForPath(java.io.File)`
- `https://developer.android.com/reference/android/content/pm/ApplicationInfo#storageUuid`

## Public methods

### allocateBytes

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

```
public void allocateBytes (FileDescriptor fd, 
                long bytes)
```

Allocate the requested number of bytes for your application to use in the given open file. This will cause the system to delete any cached files necessary to satisfy your request.

Attempts to allocate disk space beyond the value returned by `https://developer.android.com/reference/android/os/storage/StorageManager#getAllocatableBytes(java.util.UUID)` will fail.

This method guarantees that bytes have been allocated to the opened file, otherwise it will throw if fast allocation is not possible. Fast allocation is typically only supported in private app data directories, and on shared/external storage devices which are emulated.

If you're progressively allocating an unbounded amount of storage space (such as when recording a video) you should avoid calling this method more than once every 60 seconds.   

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

<br />

| Parameters ||
|---|---|
| `fd` | `FileDescriptor`: the open file that you'd like to allocate disk space for. <br /> |
| `bytes` | `long`: the number of bytes to allocate. This is the desired final size of the open file. If the open file is smaller than this requested size, it will be extended without modifying any existing contents. If the open file is larger than this requested size, it will be truncated. 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, or when it doesn't support allocating space, or if the device had trouble allocating the requested space. |

**See also:**

- `https://developer.android.com/reference/android/os/storage/StorageManager#isAllocationSupported(java.io.FileDescriptor)`
- `https://developer.android.com/reference/android/os/Environment#isExternalStorageEmulated(java.io.File)`

### allocateBytes

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

```
public void allocateBytes (UUID storageUuid, 
                long bytes)
```

Allocate the requested number of bytes for your application to use on the given storage volume. This will cause the system to delete any cached files necessary to satisfy your request.

Attempts to allocate disk space beyond the value returned by `https://developer.android.com/reference/android/os/storage/StorageManager#getAllocatableBytes(java.util.UUID)` will fail.

Since multiple apps can be running simultaneously, this method may be subject to race conditions. If possible, consider using `https://developer.android.com/reference/android/os/storage/StorageManager#allocateBytes(java.io.FileDescriptor,%20long)` which will guarantee that bytes are allocated to an opened file.

If you're progressively allocating an unbounded amount of storage space (such as when recording a video) you should avoid calling this method more than once every 60 seconds.   

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

<br />

| Parameters ||
|---|---|
| `storageUuid` | `UUID`: the UUID of the storage volume where you'd like to allocate disk space. The UUID for a specific path can be obtained using `https://developer.android.com/reference/android/os/storage/StorageManager#getUuidForPath(java.io.File)`. This value cannot be `null`. <br /> |
| `bytes` | `long`: the number of bytes to allocate. 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, or when it doesn't support allocating space, or if the device had trouble allocating the requested space. |

**See also:**

- `https://developer.android.com/reference/android/os/storage/StorageManager#getAllocatableBytes(java.util.UUID)`

### getAllocatableBytes

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

```
public long getAllocatableBytes (UUID storageUuid)
```

Return the maximum number of new bytes that your app can allocate for itself on the given storage volume. This value is typically larger than `https://developer.android.com/reference/java/io/File#getUsableSpace()`, since the system may be willing to delete cached files to satisfy an allocation request. You can then allocate space for yourself using `https://developer.android.com/reference/android/os/storage/StorageManager#allocateBytes(java.util.UUID,%20long)` or `https://developer.android.com/reference/android/os/storage/StorageManager#allocateBytes(java.io.FileDescriptor,%20long)`.

This method is best used as a pre-flight check, such as deciding if there is enough space to store an entire music album before you allocate space for each audio file in the album. Attempts to allocate disk space beyond the returned value will fail.

If the returned value is not large enough for the data you'd like to persist, you can launch `https://developer.android.com/reference/android/os/storage/StorageManager#ACTION_MANAGE_STORAGE` with the `https://developer.android.com/reference/android/os/storage/StorageManager#EXTRA_UUID` and `https://developer.android.com/reference/android/os/storage/StorageManager#EXTRA_REQUESTED_BYTES` options to help involve the user in freeing up disk space.

If you're progressively allocating an unbounded amount of storage space (such as when recording a video) you should avoid calling this method more than once every 30 seconds.

Note: if your app uses the `android:sharedUserId` manifest feature, then allocatable space for all packages in your shared UID is tracked together as a single unit.
.   
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 />

<br />

| Parameters ||
|---|---|
| `storageUuid` | `UUID`: the UUID of the storage volume where you're considering allocating disk space, since allocatable space can vary widely depending on the underlying storage device. The UUID for a specific path can be obtained using `https://developer.android.com/reference/android/os/storage/StorageManager#getUuidForPath(java.io.File)`. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `long` | the maximum number of new bytes that the calling app can allocate using `https://developer.android.com/reference/android/os/storage/StorageManager#allocateBytes(java.util.UUID,%20long)` or `https://developer.android.com/reference/android/os/storage/StorageManager#allocateBytes(java.io.FileDescriptor,%20long)`. 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, or when it doesn't support allocating space. |

### getCacheQuotaBytes

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

```
public long getCacheQuotaBytes (UUID storageUuid)
```

Return quota size in bytes for all cached data belonging to the calling app on the given storage volume.

If your app goes above this quota, your cached files will be some of the first to be deleted when additional disk space is needed. Conversely, if your app stays under this quota, your cached files will be some of the last to be deleted when additional disk space is needed.

This quota will change over time depending on how frequently the user interacts with your app, and depending on how much system-wide disk space is used.

Note: if your app uses the `android:sharedUserId` manifest feature, then cached data for all packages in your shared UID is tracked together as a single unit.
.   
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 />

<br />

| Parameters ||
|---|---|
| `storageUuid` | `UUID`: the UUID of the storage volume that you're interested in. The UUID for a specific path can be obtained using `https://developer.android.com/reference/android/os/storage/StorageManager#getUuidForPath(java.io.File)`. 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, or when it doesn't support cache quotas. |

**See also:**

- `https://developer.android.com/reference/android/os/storage/StorageManager#getCacheSizeBytes(java.util.UUID)`

### getCacheSizeBytes

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

```
public long getCacheSizeBytes (UUID storageUuid)
```

Return total size in bytes of all cached data belonging to the calling app on the given storage volume.

Cached data tracked by this method always includes `https://developer.android.com/reference/android/content/Context#getCacheDir()` and `https://developer.android.com/reference/android/content/Context#getCodeCacheDir()`, and it also includes `https://developer.android.com/reference/android/content/Context#getExternalCacheDir()` if the primary shared/external storage is hosted on the same storage device as your private data.

Note: if your app uses the `android:sharedUserId` manifest feature, then cached data for all packages in your shared UID is tracked together as a single unit.
.   
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 />

<br />

| Parameters ||
|---|---|
| `storageUuid` | `UUID`: the UUID of the storage volume that you're interested in. The UUID for a specific path can be obtained using `https://developer.android.com/reference/android/os/storage/StorageManager#getUuidForPath(java.io.File)`. 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, or when it doesn't support cache quotas. |

**See also:**

- `https://developer.android.com/reference/android/os/storage/StorageManager#getCacheQuotaBytes(java.util.UUID)`

### getManageSpaceActivityIntent

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

```
public PendingIntent getManageSpaceActivityIntent (String packageName, 
                int requestCode)
```

Returns a `https://developer.android.com/reference/android/app/PendingIntent` that can be used by Apps with `https://developer.android.com/reference/android/Manifest.permission#MANAGE_EXTERNAL_STORAGE` permission to launch the manageSpaceActivity for any App that implements it, irrespective of its exported status.

Caller has the responsibility of supplying a valid packageName which has manageSpaceActivity implemented.   

Requires `https://developer.android.com/reference/android/Manifest.permission#MANAGE_EXTERNAL_STORAGE`

<br />

| Parameters ||
|---|---|
| `packageName` | `String`: package name for the App for which manageSpaceActivity is to be launched. This value cannot be `null`. <br /> |
| `requestCode` | `int`: for launching the activity <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/PendingIntent` | PendingIntent to launch the manageSpaceActivity if successful, null if the packageName doesn't have a manageSpaceActivity. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | an invalid packageName is supplied. |

### getMountedObbPath

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

```
public String getMountedObbPath (String rawPath)
```

Check the mounted path of an Opaque Binary Blob (OBB) file. This will give you the path to where you can obtain access to the internals of the OBB.

<br />

| Parameters ||
|---|---|
| `rawPath` | `String`: path to OBB image <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | absolute path to mounted OBB image data or `null` if not mounted or exception encountered trying to read status <br /> |

### getPrimaryStorageVolume

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

```
public StorageVolume getPrimaryStorageVolume ()
```

Return the primary shared/external storage volume available to the current user. This volume is the same storage device returned by `https://developer.android.com/reference/android/os/Environment#getExternalStorageDirectory()` and `https://developer.android.com/reference/android/content/Context#getExternalFilesDir(java.lang.String)`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/os/storage/StorageVolume` | This value cannot be `null`. <br /> |

### getRecentStorageVolumes

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

```
public List<StorageVolume> getRecentStorageVolumes ()
```

Return the list of shared/external storage volumes both currently and recently available to the calling user.

Recently available storage volumes are likely to reappear in the future, so apps are encouraged to preserve any indexed metadata related to these volumes to optimize user experiences.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/os/storage/StorageVolume>` | This value cannot be `null`. <br /> |

### getStorageVolume

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

```
public StorageVolume getStorageVolume (File file)
```

Return the `https://developer.android.com/reference/android/os/storage/StorageVolume` that contains the given file, or `null` if none.

<br />

| Parameters ||
|---|---|
| `file` | `File`: This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/os/storage/StorageVolume` | <br /> |

### getStorageVolume

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

```
public StorageVolume getStorageVolume (Uri uri)
```

Return the `https://developer.android.com/reference/android/os/storage/StorageVolume` that contains the given `https://developer.android.com/reference/android/provider/MediaStore` item.

<br />

| Parameters ||
|---|---|
| `uri` | `Uri`: This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/os/storage/StorageVolume` | This value cannot be `null`. <br /> |

### getStorageVolumes

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

```
public List<StorageVolume> getStorageVolumes ()
```

Return the list of shared/external storage volumes currently available to the calling user.

These storage volumes are actively attached to the device, but may be in any mount state, as returned by `https://developer.android.com/reference/android/os/storage/StorageVolume#getState()`. Returns both the primary shared storage device and any attached external volumes, including SD cards and USB drives.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/os/storage/StorageVolume>` | This value cannot be `null`. <br /> |

### getStorageVolumesIncludingSharedProfiles

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

```
public List<StorageVolume> getStorageVolumesIncludingSharedProfiles ()
```

Return the list of shared/external storage volumes currently available to the calling user and the user it shares media with. Please refer to [multi-user support](https://source.android.com/compatibility/12/android-12-cdd#95_multi-user_support) for more details.

This is similar to `https://developer.android.com/reference/android/os/storage/StorageManager#getStorageVolumes()` except that the result also includes the volumes belonging to any user it shares media with.   

Requires `https://developer.android.com/reference/android/Manifest.permission#MANAGE_EXTERNAL_STORAGE`

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/os/storage/StorageVolume>` | This value cannot be `null`. <br /> |

### getUuidForPath

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

```
public UUID getUuidForPath (File path)
```

Return a UUID identifying the storage volume that hosts the given filesystem path.

If this path is hosted by the default internal storage of the device at `https://developer.android.com/reference/android/os/Environment#getDataDirectory()`, the returned value will be `https://developer.android.com/reference/android/os/storage/StorageManager#UUID_DEFAULT`.

<br />

| Parameters ||
|---|---|
| `path` | `File`: This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/UUID` | This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` | when the storage device hosting the given path isn't present, or when it doesn't have a valid UUID. |

### isAllocationSupported

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

```
public boolean isAllocationSupported (FileDescriptor fd)
```

Test if the given file descriptor supports allocation of disk space using `https://developer.android.com/reference/android/os/storage/StorageManager#allocateBytes(java.io.FileDescriptor,%20long)`.

<br />

| Parameters ||
|---|---|
| `fd` | `FileDescriptor`: This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | <br /> |

### isCacheBehaviorGroup

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

```
public boolean isCacheBehaviorGroup (File path)
```

Read the current value set by `https://developer.android.com/reference/android/os/storage/StorageManager#setCacheBehaviorGroup(java.io.File,%20boolean)`.

<br />

| Parameters ||
|---|---|
| `path` | `File` <br /> |

| Returns ||
|---|---|
| `boolean` | <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` |   |

### isCacheBehaviorTombstone

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

```
public boolean isCacheBehaviorTombstone (File path)
```

Read the current value set by `https://developer.android.com/reference/android/os/storage/StorageManager#setCacheBehaviorTombstone(java.io.File,%20boolean)`.

<br />

| Parameters ||
|---|---|
| `path` | `File` <br /> |

| Returns ||
|---|---|
| `boolean` | <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` |   |

### isCheckpointSupported

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

```
public boolean isCheckpointSupported ()
```

Check whether the device supports filesystem checkpoint.

<br />

| Returns ||
|---|---|
| `boolean` | true if the device supports filesystem checkpoint, false otherwise. <br /> |

### isEncrypted

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

```
public boolean isEncrypted (File file)
```

Return if data stored at or under the given path will be encrypted while at rest. This can help apps avoid the overhead of double-encrypting data.

<br />

| Parameters ||
|---|---|
| `file` | `File` <br /> |

| Returns ||
|---|---|
| `boolean` | <br /> |

### isObbMounted

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

```
public boolean isObbMounted (String rawPath)
```

Check whether an Opaque Binary Blob (OBB) is mounted or not.

<br />

| Parameters ||
|---|---|
| `rawPath` | `String`: path to OBB image <br /> |

| Returns ||
|---|---|
| `boolean` | true if OBB is mounted; false if not mounted or on error <br /> |

### mountObb

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

```
public boolean mountObb (String rawPath, 
                String key, 
                OnObbStateChangeListener listener)
```

Mount an Opaque Binary Blob (OBB) file.

The OBB will remain mounted for as long as the StorageManager reference is held by the application. As soon as this reference is lost, the OBBs in use will be unmounted. The `https://developer.android.com/reference/android/os/storage/OnObbStateChangeListener` registered with this call will receive the success or failure of this operation.

*Note:* you can only mount OBB files for which the OBB tag on the file matches a package ID that is owned by the calling program's UID. That is, shared UID applications can attempt to mount any other application's OBB that shares its UID.

<br />

| Parameters ||
|---|---|
| `rawPath` | `String`: the path to the OBB file <br /> |
| `key` | `String`: must be `null`. Previously, some Android device implementations accepted a non-`null` key to mount an encrypted OBB file. However, this never worked reliably and is no longer supported. <br /> |
| `listener` | `OnObbStateChangeListener`: will receive the success or failure of the operation <br /> |

| Returns ||
|---|---|
| `boolean` | whether the mount call was successfully queued or not <br /> |

### openProxyFileDescriptor

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

```
public ParcelFileDescriptor openProxyFileDescriptor (int mode, 
                ProxyFileDescriptorCallback callback, 
                Handler handler)
```

Opens a seekable `https://developer.android.com/reference/android/os/ParcelFileDescriptor` that proxies all low-level I/O requests back to the given `https://developer.android.com/reference/android/os/ProxyFileDescriptorCallback`.

This can be useful when you want to provide quick access to a large file that isn't backed by a real file on disk, such as a file on a network share, cloud storage service, etc. As an example, you could respond to a `https://developer.android.com/reference/android/content/ContentResolver#openFileDescriptor(android.net.Uri,%20java.lang.String)` request by returning a `https://developer.android.com/reference/android/os/ParcelFileDescriptor` created with this method, and then stream the content on-demand as requested.

Another useful example might be where you have an encrypted file that you're willing to decrypt on-demand, but where you want to avoid persisting the cleartext version.

<br />

| Parameters ||
|---|---|
| `mode` | `int`: The desired access mode, must be one of `https://developer.android.com/reference/android/os/ParcelFileDescriptor#MODE_READ_ONLY`, `https://developer.android.com/reference/android/os/ParcelFileDescriptor#MODE_WRITE_ONLY`, or `https://developer.android.com/reference/android/os/ParcelFileDescriptor#MODE_READ_WRITE` <br /> |
| `callback` | `ProxyFileDescriptorCallback`: Callback to process file operation requests issued on returned file descriptor. <br /> |
| `handler` | `Handler`: Handler that invokes callback methods. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/os/ParcelFileDescriptor` | Seekable ParcelFileDescriptor. This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` |   |

### registerStorageVolumeCallback

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

```
public void registerStorageVolumeCallback (Executor executor, 
                StorageManager.StorageVolumeCallback callback)
```

Registers the given callback to listen for `https://developer.android.com/reference/android/os/storage/StorageVolume` changes.

For example, this can be used to detect when a volume changes to the `https://developer.android.com/reference/android/os/Environment#MEDIA_MOUNTED` or `https://developer.android.com/reference/android/os/Environment#MEDIA_UNMOUNTED` states.

<br />

| Parameters ||
|---|---|
| `executor` | `Executor`: Callback and listener events are dispatched through this `https://developer.android.com/reference/java/util/concurrent/Executor`, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use `https://developer.android.com/reference/android/content/Context#getMainExecutor()`. Otherwise, provide an `https://developer.android.com/reference/java/util/concurrent/Executor` that dispatches to an appropriate thread. This value cannot be `null`. <br /> |
| `callback` | `StorageManager.StorageVolumeCallback`: This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/os/storage/StorageManager#unregisterStorageVolumeCallback(android.os.storage.StorageManager.StorageVolumeCallback)`

### setCacheBehaviorGroup

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

```
public void setCacheBehaviorGroup (File path, 
                boolean group)
```

Enable or disable special cache behavior that treats this directory and its contents as an entire group.

When enabled and this directory is considered for automatic deletion by the OS, all contained files will either be deleted together, or not at all. This is useful when you have a directory that contains several related metadata files that depend on each other, such as movie file and a subtitle file.

When enabled, the *newest* `https://developer.android.com/reference/java/io/File#lastModified()` value of any contained files is considered the modified time of the entire directory.

This behavior can only be set on a directory, and it applies recursively to all contained files and directories.

<br />

| Parameters ||
|---|---|
| `path` | `File` <br /> |
| `group` | `boolean` <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` |   |

### setCacheBehaviorTombstone

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

```
public void setCacheBehaviorTombstone (File path, 
                boolean tombstone)
```

Enable or disable special cache behavior that leaves deleted cache files intact as tombstones.

When enabled and a file contained in this directory is automatically deleted by the OS, the file will be truncated to have a length of 0 bytes instead of being fully deleted. This is useful if you need to distinguish between a file that was deleted versus one that never existed.

This behavior can only be set on a directory, and it applies recursively to all contained files and directories.

Note: this behavior is ignored completely if the user explicitly requests that all cached data be cleared.

<br />

<br />

| Parameters ||
|---|---|
| `path` | `File` <br /> |
| `tombstone` | `boolean` <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` |   |

### unmountObb

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

```
public boolean unmountObb (String rawPath, 
                boolean force, 
                OnObbStateChangeListener listener)
```

Unmount an Opaque Binary Blob (OBB) file asynchronously. If the `force` flag is true, it will kill any application needed to unmount the given OBB (even the calling application).

The `https://developer.android.com/reference/android/os/storage/OnObbStateChangeListener` registered with this call will receive the success or failure of this operation.

*Note:* you can only mount OBB files for which the OBB tag on the file matches a package ID that is owned by the calling program's UID. That is, shared UID applications can obtain access to any other application's OBB that shares its UID.

<br />

<br />

| Parameters ||
|---|---|
| `rawPath` | `String`: path to the OBB file <br /> |
| `force` | `boolean`: whether to kill any programs using this in order to unmount it <br /> |
| `listener` | `OnObbStateChangeListener`: will receive the success or failure of the operation <br /> |

| Returns ||
|---|---|
| `boolean` | whether the unmount call was successfully queued or not <br /> |

### unregisterStorageVolumeCallback

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

```
public void unregisterStorageVolumeCallback (StorageManager.StorageVolumeCallback callback)
```

Unregisters the given callback from listening for `https://developer.android.com/reference/android/os/storage/StorageVolume` changes.

<br />

| Parameters ||
|---|---|
| `callback` | `StorageManager.StorageVolumeCallback`: This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/os/storage/StorageManager#registerStorageVolumeCallback(java.util.concurrent.Executor,%20android.os.storage.StorageManager.StorageVolumeCallback)`