# EnvironmentCompat

# EnvironmentCompat

Artifact:[androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core)  
[View Source](https://cs.android.com/search?q=file:androidx/core/os/EnvironmentCompat.java+class:androidx.core.os.EnvironmentCompat)  
Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/core/os/EnvironmentCompat "View this page in Java")

<br />

```
class EnvironmentCompat
```

<br />

*** ** * ** ***

Helper for accessing features in[Environment](https://developer.android.com/reference/android/os/Environment.html).

## Summary

|                                        ### Constants                                         |
|----------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `const `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!` | [MEDIA_UNKNOWN](https://developer.android.com/reference/kotlin/androidx/core/os/EnvironmentCompat#MEDIA_UNKNOWN())` = "unknown"` **This property is deprecated.** Use[MEDIA_UNKNOWN](https://developer.android.com/reference/android/os/Environment.html#MEDIA_UNKNOWN())directly. <br /> |

|                                      ### Public functions                                       |
|-------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `java-static `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | [getStorageState](https://developer.android.com/reference/kotlin/androidx/core/os/EnvironmentCompat#getStorageState(java.io.File))`(path: `[File](https://developer.android.com/reference/java/io/File.html)`)` Returns the current state of the storage device that provides the given path. |

## Constants

### MEDIA_UNKNOWN

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  
Deprecated in[1.13.0](https://developer.android.com/jetpack/androidx/releases/core#1.13.0)  

```
const val MEDIA_UNKNOWN = "unknown": String!
```
| **This property is deprecated.**   
|
| Use[MEDIA_UNKNOWN](https://developer.android.com/reference/android/os/Environment.html#MEDIA_UNKNOWN())directly.

Unknown storage state, such as when a path isn't backed by known storage media.  

|                                                              See also                                                              |
|------------------------------------------------------------------------------------------------------------------------------------|---|
| [getStorageState](https://developer.android.com/reference/kotlin/androidx/core/os/EnvironmentCompat#getStorageState(java.io.File)) |   |

## Public functions

### getStorageState

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
java-static fun getStorageState(path: File): String
```

Returns the current state of the storage device that provides the given path.  

|                                      Returns                                      |
|-----------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | one of[MEDIA_UNKNOWN](https://developer.android.com/reference/android/os/Environment.html#MEDIA_UNKNOWN()),[MEDIA_REMOVED](https://developer.android.com/reference/android/os/Environment.html#MEDIA_REMOVED()),[MEDIA_UNMOUNTED](https://developer.android.com/reference/android/os/Environment.html#MEDIA_UNMOUNTED()),[MEDIA_CHECKING](https://developer.android.com/reference/android/os/Environment.html#MEDIA_CHECKING()),[MEDIA_NOFS](https://developer.android.com/reference/android/os/Environment.html#MEDIA_NOFS()),[MEDIA_MOUNTED](https://developer.android.com/reference/android/os/Environment.html#MEDIA_MOUNTED()),[MEDIA_MOUNTED_READ_ONLY](https://developer.android.com/reference/android/os/Environment.html#MEDIA_MOUNTED_READ_ONLY()),[MEDIA_SHARED](https://developer.android.com/reference/android/os/Environment.html#MEDIA_SHARED()),[MEDIA_BAD_REMOVAL](https://developer.android.com/reference/android/os/Environment.html#MEDIA_BAD_REMOVAL()), or[MEDIA_UNMOUNTABLE](https://developer.android.com/reference/android/os/Environment.html#MEDIA_UNMOUNTABLE()). |