StorageManager.StorageVolumeCallback

public static class StorageManager.StorageVolumeCallback
extends Object

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


Callback that delivers StorageVolume related events.

For example, this can be used to detect when a volume changes to the Environment#MEDIA_MOUNTED or Environment#MEDIA_UNMOUNTED states.

Summary

Public constructors

StorageVolumeCallback()

Public methods

void onStateChanged(StorageVolume volume)

Called when StorageVolume#getState() changes, such as changing to the Environment#MEDIA_MOUNTED or Environment#MEDIA_UNMOUNTED states.

Inherited methods

Public constructors

StorageVolumeCallback

public StorageVolumeCallback ()

Public methods

onStateChanged

Added in API level 30
public void onStateChanged (StorageVolume volume)

Called when StorageVolume#getState() changes, such as changing to the Environment#MEDIA_MOUNTED or Environment#MEDIA_UNMOUNTED states.

The given argument is a snapshot in time and can be used to process events in the order they occurred, or you can call StorageManager#getStorageVolumes() to observe the latest value.

Parameters
volume StorageVolume: This value cannot be null.