to top
Android APIs
public class

StorageManager

extends Object
java.lang.Object
   ↳ android.os.storage.StorageManager

Class Overview

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.

Get an instance of this class by calling getSystemService(java.lang.String) with an argument of STORAGE_SERVICE.

Summary

Public Methods
String getMountedObbPath(String filename)
Check the mounted path of an Opaque Binary Blob (OBB) file.
boolean isObbMounted(String filename)
Check whether an Opaque Binary Blob (OBB) is mounted or not.
boolean mountObb(String filename, String key, OnObbStateChangeListener listener)
Mount an Opaque Binary Blob (OBB) file.
boolean unmountObb(String filename, boolean force, OnObbStateChangeListener listener)
Unmount an Opaque Binary Blob (OBB) file asynchronously.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public String getMountedObbPath (String filename)

Since: API Level 9

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.

Parameters
filename path to OBB image
Returns
  • absolute path to mounted OBB image data or null if not mounted or exception encountered trying to read status

public boolean isObbMounted (String filename)

Since: API Level 9

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

Parameters
filename path to OBB image
Returns
  • true if OBB is mounted; false if not mounted or on error

public boolean mountObb (String filename, String key, OnObbStateChangeListener listener)

Since: API Level 9

Mount an Opaque Binary Blob (OBB) file. If a key is specified, it is supplied to the mounting process to be used in any encryption used in the OBB.

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

Parameters
filename the path to the OBB file
key secret used to encrypt the OBB; may be null if no encryption was used on the OBB.
listener will receive the success or failure of the operation
Returns
  • whether the mount call was successfully queued or not

public boolean unmountObb (String filename, boolean force, OnObbStateChangeListener listener)

Since: API Level 9

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

Parameters
filename path to the OBB file
force whether to kill any programs using this in order to unmount it
listener will receive the success or failure of the operation
Returns
  • whether the unmount call was successfully queued or not