Stay organized with collections
Save and categorize content based on your preferences.
StorageVolumeCallback
open class 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
StorageVolumeCallback()
Public methods
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# StorageManager.StorageVolumeCallback\n\nAdded in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nStorageVolumeCallback\n=====================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/os/storage/StorageManager.StorageVolumeCallback \"View this page in Java\") \n\n```\nopen class StorageVolumeCallback\n```\n\n|---|--------------------------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.os.storage.StorageManager.StorageVolumeCallback](#) |\n\nCallback that delivers [StorageVolume](/reference/kotlin/android/os/storage/StorageVolume) related events.\n\nFor example, this can be used to detect when a volume changes to the [Environment.MEDIA_MOUNTED](../Environment.html#MEDIA_MOUNTED:kotlin.String) or [Environment.MEDIA_UNMOUNTED](../Environment.html#MEDIA_UNMOUNTED:kotlin.String) states.\n\nSummary\n-------\n\n| Public constructors ||\n|--------------------------------------------------------------|---|\n| [StorageVolumeCallback](#StorageVolumeCallback())`()` \u003cbr /\u003e |\n\n| Public methods ||\n|-----------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onStateChanged](#onStateChanged(android.os.storage.StorageVolume))`(`volume:` `[StorageVolume](/reference/kotlin/android/os/storage/StorageVolume)`)` Called when [StorageVolume.getState()](/reference/kotlin/android/os/storage/StorageVolume#getState()) changes, such as changing to the [Environment.MEDIA_MOUNTED](../Environment.html#MEDIA_MOUNTED:kotlin.String) or [Environment.MEDIA_UNMOUNTED](../Environment.html#MEDIA_UNMOUNTED:kotlin.String) states. |\n\nPublic constructors\n-------------------\n\n### StorageVolumeCallback\n\n```\nStorageVolumeCallback()\n```\n\nPublic methods\n--------------\n\n### onStateChanged\n\nAdded in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun onStateChanged(volume: StorageVolume): Unit\n```\n\nCalled when [StorageVolume.getState()](/reference/kotlin/android/os/storage/StorageVolume#getState()) changes, such as changing to the [Environment.MEDIA_MOUNTED](../Environment.html#MEDIA_MOUNTED:kotlin.String) or [Environment.MEDIA_UNMOUNTED](../Environment.html#MEDIA_UNMOUNTED:kotlin.String) states.\n\nThe 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()](/reference/kotlin/android/os/storage/StorageManager#getStorageVolumes()) to observe the latest value.\n\n| Parameters ||\n|----------|---------------------------------------------------------------------------------------------------|\n| `volume` | [StorageVolume](/reference/kotlin/android/os/storage/StorageVolume): This value cannot be `null`. |"]]