# 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)

*** ** * ** ***


```
public final class EnvironmentCompat
```

<br />

*** ** * ** ***

Helper for accessing features in `https://developer.android.com/reference/android/os/Environment.html`.

## Summary

| ### Constants |
|---|---|
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/core/os/EnvironmentCompat#MEDIA_UNKNOWN() = "unknown"` **This field is deprecated.** Use `https://developer.android.com/reference/android/os/Environment.html#MEDIA_UNKNOWN` directly. <br /> |

| ### Public methods |
|---|---|
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/core/os/EnvironmentCompat#getStorageState(java.io.File)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/io/File.html path)` 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)

```
public static final String MEDIA_UNKNOWN = "unknown"
```

> [!CAUTION]
> **This field is deprecated.**   
>
> Use `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 |
|---|---|
| `https://developer.android.com/reference/androidx/core/os/EnvironmentCompat#getStorageState(java.io.File)` |   |

## Public methods

### getStorageState

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

```
public static @NonNull String getStorageState(@NonNull File path)
```

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

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html` | one of `https://developer.android.com/reference/android/os/Environment.html#MEDIA_UNKNOWN`, `https://developer.android.com/reference/android/os/Environment.html#MEDIA_REMOVED`, `https://developer.android.com/reference/android/os/Environment.html#MEDIA_UNMOUNTED`, `https://developer.android.com/reference/android/os/Environment.html#MEDIA_CHECKING`, `https://developer.android.com/reference/android/os/Environment.html#MEDIA_NOFS`, `https://developer.android.com/reference/android/os/Environment.html#MEDIA_MOUNTED`, `https://developer.android.com/reference/android/os/Environment.html#MEDIA_MOUNTED_READ_ONLY`, `https://developer.android.com/reference/android/os/Environment.html#MEDIA_SHARED`, `https://developer.android.com/reference/android/os/Environment.html#MEDIA_BAD_REMOVAL`, or `https://developer.android.com/reference/android/os/Environment.html#MEDIA_UNMOUNTABLE`. |