Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Constants](https://developer.android.com/reference/android/os/Environment#constants) \| [Fields](https://developer.android.com/reference/android/os/Environment#lfields) \| [Ctors](https://developer.android.com/reference/android/os/Environment#pubctors) \| [Methods](https://developer.android.com/reference/android/os/Environment#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/os/Environment#inhmethods)

# Environment

*** ** * ** ***


`
public


class
Environment
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.os.Environment |

<br />

*** ** * ** ***

Provides access to environment variables.

## Summary

| ### Constants ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/os/Environment#MEDIA_BAD_REMOVAL` Storage state if the media was removed before it was unmounted. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/os/Environment#MEDIA_CHECKING` Storage state if the media is present and being disk-checked. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/os/Environment#MEDIA_EJECTING` Storage state if the media is in the process of being ejected. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/os/Environment#MEDIA_MOUNTED` Storage state if the media is present and mounted at its mount point with read/write access. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/os/Environment#MEDIA_MOUNTED_READ_ONLY` Storage state if the media is present and mounted at its mount point with read-only access. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/os/Environment#MEDIA_NOFS` Storage state if the media is present but is blank or is using an unsupported filesystem. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/os/Environment#MEDIA_REMOVED` Storage state if the media is not present. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/os/Environment#MEDIA_SHARED` Storage state if the media is present not mounted, and shared via USB mass storage. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/os/Environment#MEDIA_UNKNOWN` Unknown storage state, such as when a path isn't backed by known storage media. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/os/Environment#MEDIA_UNMOUNTABLE` Storage state if the media is present but cannot be mounted. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/os/Environment#MEDIA_UNMOUNTED` Storage state if the media is present but not mounted. |

| ### Fields ||
|---|---|
| ` public static https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/os/Environment#DIRECTORY_ALARMS` Standard directory in which to place any audio files that should be in the list of alarms that the user can select (not as regular music). |
| ` public static https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/os/Environment#DIRECTORY_AUDIOBOOKS` Standard directory in which to place any audio files that should be in the list of audiobooks that the user can select (not as regular music). |
| ` public static https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/os/Environment#DIRECTORY_DCIM` The traditional location for pictures and videos when mounting the device as a camera. |
| ` public static https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/os/Environment#DIRECTORY_DOCUMENTS` Standard directory in which to place documents that have been created by the user. |
| ` public static https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/os/Environment#DIRECTORY_DOWNLOADS` Standard directory in which to place files that have been downloaded by the user. |
| ` public static https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/os/Environment#DIRECTORY_MOVIES` Standard directory in which to place movies that are available to the user. |
| ` public static https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/os/Environment#DIRECTORY_MUSIC` Standard directory in which to place any audio files that should be in the regular list of music for the user. |
| ` public static https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/os/Environment#DIRECTORY_NOTIFICATIONS` Standard directory in which to place any audio files that should be in the list of notifications that the user can select (not as regular music). |
| ` public static https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/os/Environment#DIRECTORY_PICTURES` Standard directory in which to place pictures that are available to the user. |
| ` public static https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/os/Environment#DIRECTORY_PODCASTS` Standard directory in which to place any audio files that should be in the list of podcasts that the user can select (not as regular music). |
| ` public static https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/os/Environment#DIRECTORY_RECORDINGS` Standard directory in which to place any audio files that should be in the list of voice recordings recorded by voice recorder apps that the user can select (not as regular music). |
| ` public static https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/os/Environment#DIRECTORY_RINGTONES` Standard directory in which to place any audio files that should be in the list of ringtones that the user can select (not as regular music). |
| ` public static https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/os/Environment#DIRECTORY_SCREENSHOTS` Standard directory in which to place screenshots that have been taken by the user. |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/os/Environment#Environment()() ` |

| ### Public methods ||
|---|---|
| ` static https://developer.android.com/reference/java/io/File` | ` https://developer.android.com/reference/android/os/Environment#getDataDirectory()() ` Return the user data directory. |
| ` static https://developer.android.com/reference/java/io/File` | ` https://developer.android.com/reference/android/os/Environment#getDownloadCacheDirectory()() ` Return the download/cache content directory. |
| ` static https://developer.android.com/reference/java/io/File` | ` https://developer.android.com/reference/android/os/Environment#getExternalStorageDirectory()() ` Return the primary shared/external storage directory. |
| ` static https://developer.android.com/reference/java/io/File` | ` https://developer.android.com/reference/android/os/Environment#getExternalStoragePublicDirectory(java.lang.String)(https://developer.android.com/reference/java/lang/String type) ` Get a top-level shared/external storage directory for placing files of a particular type. |
| ` static https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/os/Environment#getExternalStorageState()() ` Returns the current state of the primary shared/external storage media. |
| ` static https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/os/Environment#getExternalStorageState(java.io.File)(https://developer.android.com/reference/java/io/File path) ` Returns the current state of the shared/external storage media at the given path. |
| ` static https://developer.android.com/reference/java/io/File` | ` https://developer.android.com/reference/android/os/Environment#getRootDirectory()() ` Return root of the "system" partition holding the core Android OS. |
| ` static https://developer.android.com/reference/java/io/File` | ` https://developer.android.com/reference/android/os/Environment#getStorageDirectory()() ` Return root directory where all external storage devices will be mounted. |
| ` static https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/os/Environment#getStorageState(java.io.File)(https://developer.android.com/reference/java/io/File path) ` *This method was deprecated in API level 21. use `https://developer.android.com/reference/android/os/Environment#getExternalStorageState(java.io.File)`* |
| ` static boolean` | ` https://developer.android.com/reference/android/os/Environment#isExternalStorageEmulated()() ` Returns whether the primary shared/external storage media is emulated. |
| ` static boolean` | ` https://developer.android.com/reference/android/os/Environment#isExternalStorageEmulated(java.io.File)(https://developer.android.com/reference/java/io/File path) ` Returns whether the shared/external storage media at the given path is emulated. |
| ` static boolean` | ` https://developer.android.com/reference/android/os/Environment#isExternalStorageLegacy(java.io.File)(https://developer.android.com/reference/java/io/File path) ` Returns whether the shared/external storage media is a legacy view that includes files not owned by the app. |
| ` static boolean` | ` https://developer.android.com/reference/android/os/Environment#isExternalStorageLegacy()() ` Returns whether the shared/external storage media is a legacy view that includes files not owned by the app. |
| ` static boolean` | ` https://developer.android.com/reference/android/os/Environment#isExternalStorageManager()() ` Returns whether the calling app has All Files Access on the primary shared/external storage media. |
| ` static boolean` | ` https://developer.android.com/reference/android/os/Environment#isExternalStorageManager(java.io.File)(https://developer.android.com/reference/java/io/File path) ` Returns whether the calling app has All Files Access at the given `path` Declaring the permission `https://developer.android.com/reference/android/Manifest.permission#MANAGE_EXTERNAL_STORAGE` isn't enough to gain the access. |
| ` static boolean` | ` https://developer.android.com/reference/android/os/Environment#isExternalStorageRemovable(java.io.File)(https://developer.android.com/reference/java/io/File path) ` Returns whether the shared/external storage media at the given path is physically removable. |
| ` static boolean` | ` https://developer.android.com/reference/android/os/Environment#isExternalStorageRemovable()() ` Returns whether the primary shared/external storage media is physically removable. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Constants

### MEDIA_BAD_REMOVAL

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String MEDIA_BAD_REMOVAL
```

Storage state if the media was removed before it was unmounted.

<br />

**See also:**

- `https://developer.android.com/reference/android/os/Environment#getExternalStorageState(java.io.File)`

Constant Value:

"bad_removal"


### MEDIA_CHECKING

Added in [API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String MEDIA_CHECKING
```

Storage state if the media is present and being disk-checked.

<br />

**See also:**

- `https://developer.android.com/reference/android/os/Environment#getExternalStorageState(java.io.File)`

Constant Value:

"checking"


### MEDIA_EJECTING

Added in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String MEDIA_EJECTING
```

Storage state if the media is in the process of being ejected.

<br />

**See also:**

- `https://developer.android.com/reference/android/os/Environment#getExternalStorageState(java.io.File)`

Constant Value:

"ejecting"


### MEDIA_MOUNTED

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String MEDIA_MOUNTED
```

Storage state if the media is present and mounted at its mount point with
read/write access.

<br />

**See also:**

- `https://developer.android.com/reference/android/os/Environment#getExternalStorageState(java.io.File)`

Constant Value:

"mounted"


### MEDIA_MOUNTED_READ_ONLY

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String MEDIA_MOUNTED_READ_ONLY
```

Storage state if the media is present and mounted at its mount point with
read-only access.

<br />

**See also:**

- `https://developer.android.com/reference/android/os/Environment#getExternalStorageState(java.io.File)`

Constant Value:

"mounted_ro"


### MEDIA_NOFS

Added in [API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String MEDIA_NOFS
```

Storage state if the media is present but is blank or is using an
unsupported filesystem.

<br />

**See also:**

- `https://developer.android.com/reference/android/os/Environment#getExternalStorageState(java.io.File)`

Constant Value:

"nofs"


### MEDIA_REMOVED

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String MEDIA_REMOVED
```

Storage state if the media is not present.

<br />

**See also:**

- `https://developer.android.com/reference/android/os/Environment#getExternalStorageState(java.io.File)`

Constant Value:

"removed"


### MEDIA_SHARED

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String MEDIA_SHARED
```

Storage state if the media is present not mounted, and shared via USB
mass storage.

<br />

**See also:**

- `https://developer.android.com/reference/android/os/Environment#getExternalStorageState(java.io.File)`

Constant Value:

"shared"


### MEDIA_UNKNOWN

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String MEDIA_UNKNOWN
```

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

<br />

**See also:**

- `https://developer.android.com/reference/android/os/Environment#getExternalStorageState(java.io.File)`

Constant Value:

"unknown"


### MEDIA_UNMOUNTABLE

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String MEDIA_UNMOUNTABLE
```

Storage state if the media is present but cannot be mounted. Typically
this happens if the file system on the media is corrupted.

<br />

**See also:**

- `https://developer.android.com/reference/android/os/Environment#getExternalStorageState(java.io.File)`

Constant Value:

"unmountable"


### MEDIA_UNMOUNTED

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String MEDIA_UNMOUNTED
```

Storage state if the media is present but not mounted.

<br />

**See also:**

- `https://developer.android.com/reference/android/os/Environment#getExternalStorageState(java.io.File)`

Constant Value:

"unmounted"


## Fields

### DIRECTORY_ALARMS

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static String DIRECTORY_ALARMS
```

Standard directory in which to place any audio files that should be
in the list of alarms that the user can select (not as regular
music).
This may be combined with `https://developer.android.com/reference/android/os/Environment#DIRECTORY_MUSIC`,
`https://developer.android.com/reference/android/os/Environment#DIRECTORY_AUDIOBOOKS`, `https://developer.android.com/reference/android/os/Environment#DIRECTORY_PODCASTS`,
`https://developer.android.com/reference/android/os/Environment#DIRECTORY_NOTIFICATIONS`, `https://developer.android.com/reference/android/os/Environment#DIRECTORY_RINGTONES`,
and `https://developer.android.com/reference/android/os/Environment#DIRECTORY_RECORDINGS` as a series of directories
to categorize a particular audio file as more than one type.

<br />

### DIRECTORY_AUDIOBOOKS

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static String DIRECTORY_AUDIOBOOKS
```

Standard directory in which to place any audio files that should be
in the list of audiobooks that the user can select (not as regular
music).
This may be combined with `https://developer.android.com/reference/android/os/Environment#DIRECTORY_MUSIC`,
`https://developer.android.com/reference/android/os/Environment#DIRECTORY_PODCASTS`, `https://developer.android.com/reference/android/os/Environment#DIRECTORY_NOTIFICATIONS`,
`https://developer.android.com/reference/android/os/Environment#DIRECTORY_ALARMS`, `https://developer.android.com/reference/android/os/Environment#DIRECTORY_RINGTONES`,
and `https://developer.android.com/reference/android/os/Environment#DIRECTORY_RECORDINGS` as a series of directories
to categorize a particular audio file as more than one type.

<br />

### DIRECTORY_DCIM

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static String DIRECTORY_DCIM
```

The traditional location for pictures and videos when mounting the
device as a camera. Note that this is primarily a convention for the
top-level public directory, as this convention makes no sense elsewhere.

<br />

### DIRECTORY_DOCUMENTS

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static String DIRECTORY_DOCUMENTS
```

Standard directory in which to place documents that have been created by
the user.

<br />

### DIRECTORY_DOWNLOADS

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static String DIRECTORY_DOWNLOADS
```

Standard directory in which to place files that have been downloaded by
the user. Note that this is primarily a convention for the top-level
public directory, you are free to download files anywhere in your own
private directories. Also note that though the constant here is
named DIRECTORY_DOWNLOADS (plural), the actual file name is non-plural for
backwards compatibility reasons.

<br />

### DIRECTORY_MOVIES

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static String DIRECTORY_MOVIES
```

Standard directory in which to place movies that are available to
the user. Note that this is primarily a convention for the top-level
public directory, as the media scanner will find and collect movies
in any directory.

<br />

### DIRECTORY_MUSIC

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static String DIRECTORY_MUSIC
```

Standard directory in which to place any audio files that should be
in the regular list of music for the user.
This may be combined with `https://developer.android.com/reference/android/os/Environment#DIRECTORY_AUDIOBOOKS`,
`https://developer.android.com/reference/android/os/Environment#DIRECTORY_PODCASTS`, `https://developer.android.com/reference/android/os/Environment#DIRECTORY_NOTIFICATIONS`,
`https://developer.android.com/reference/android/os/Environment#DIRECTORY_ALARMS`, `https://developer.android.com/reference/android/os/Environment#DIRECTORY_RINGTONES`, and
`https://developer.android.com/reference/android/os/Environment#DIRECTORY_RECORDINGS` as a series of directories to
categorize a particular audio file as more than one type.

<br />

### DIRECTORY_NOTIFICATIONS

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static String DIRECTORY_NOTIFICATIONS
```

Standard directory in which to place any audio files that should be
in the list of notifications that the user can select (not as regular
music).
This may be combined with `https://developer.android.com/reference/android/os/Environment#DIRECTORY_MUSIC`,
`https://developer.android.com/reference/android/os/Environment#DIRECTORY_AUDIOBOOKS`, `https://developer.android.com/reference/android/os/Environment#DIRECTORY_PODCASTS`,
`https://developer.android.com/reference/android/os/Environment#DIRECTORY_ALARMS`, `https://developer.android.com/reference/android/os/Environment#DIRECTORY_RINGTONES`, and
`https://developer.android.com/reference/android/os/Environment#DIRECTORY_RECORDINGS` as a series of directories to
categorize a particular audio file as more than one type.

<br />

### DIRECTORY_PICTURES

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static String DIRECTORY_PICTURES
```

Standard directory in which to place pictures that are available to
the user. Note that this is primarily a convention for the top-level
public directory, as the media scanner will find and collect pictures
in any directory.

<br />

### DIRECTORY_PODCASTS

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static String DIRECTORY_PODCASTS
```

Standard directory in which to place any audio files that should be
in the list of podcasts that the user can select (not as regular
music).
This may be combined with `https://developer.android.com/reference/android/os/Environment#DIRECTORY_MUSIC`,
`https://developer.android.com/reference/android/os/Environment#DIRECTORY_AUDIOBOOKS`, `https://developer.android.com/reference/android/os/Environment#DIRECTORY_NOTIFICATIONS`,
`https://developer.android.com/reference/android/os/Environment#DIRECTORY_ALARMS`, `https://developer.android.com/reference/android/os/Environment#DIRECTORY_RINGTONES`, and
`https://developer.android.com/reference/android/os/Environment#DIRECTORY_RECORDINGS` as a series of directories to
categorize a particular audio file as more than one type.

<br />

### DIRECTORY_RECORDINGS

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static String DIRECTORY_RECORDINGS
```

Standard directory in which to place any audio files that should be
in the list of voice recordings recorded by voice recorder apps that
the user can select (not as regular music).
This may be combined with `https://developer.android.com/reference/android/os/Environment#DIRECTORY_MUSIC`,
`https://developer.android.com/reference/android/os/Environment#DIRECTORY_AUDIOBOOKS`, `https://developer.android.com/reference/android/os/Environment#DIRECTORY_PODCASTS`,
`https://developer.android.com/reference/android/os/Environment#DIRECTORY_NOTIFICATIONS`, `https://developer.android.com/reference/android/os/Environment#DIRECTORY_ALARMS`,
and `https://developer.android.com/reference/android/os/Environment#DIRECTORY_RINGTONES` as a series of directories
to categorize a particular audio file as more than one type.

<br />

### DIRECTORY_RINGTONES

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static String DIRECTORY_RINGTONES
```

Standard directory in which to place any audio files that should be
in the list of ringtones that the user can select (not as regular
music).
This may be combined with `https://developer.android.com/reference/android/os/Environment#DIRECTORY_MUSIC`,
`https://developer.android.com/reference/android/os/Environment#DIRECTORY_AUDIOBOOKS`, `https://developer.android.com/reference/android/os/Environment#DIRECTORY_PODCASTS`,
`https://developer.android.com/reference/android/os/Environment#DIRECTORY_NOTIFICATIONS`, `https://developer.android.com/reference/android/os/Environment#DIRECTORY_ALARMS`,
and `https://developer.android.com/reference/android/os/Environment#DIRECTORY_RECORDINGS` as a series of directories
to categorize a particular audio file as more than one type.

<br />

### DIRECTORY_SCREENSHOTS

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static String DIRECTORY_SCREENSHOTS
```

Standard directory in which to place screenshots that have been taken by
the user. Typically used as a secondary directory under
`https://developer.android.com/reference/android/os/Environment#DIRECTORY_PICTURES`.

<br />

## Public constructors

### Environment

```
public Environment ()
```

<br />

<br />

## Public methods

### getDataDirectory

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static File getDataDirectory ()
```

Return the user data directory.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/io/File` | <br /> |

### getDownloadCacheDirectory

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static File getDownloadCacheDirectory ()
```

Return the download/cache content directory.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/io/File` | <br /> |

### getExternalStorageDirectory

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static File getExternalStorageDirectory ()
```

Return the primary shared/external storage directory. This directory may
not currently be accessible if it has been mounted by the user on their
computer, has been removed from the device, or some other problem has
happened. You can determine its current state with
`https://developer.android.com/reference/android/os/Environment#getExternalStorageState()`.


*Note: don't be confused by the word "external" here. This directory
can better be thought as media/shared storage. It is a filesystem that
can hold a relatively large amount of data and that is shared across all
applications (does not enforce permissions). Traditionally this is an SD
card, but it may also be implemented as built-in storage in a device that
is distinct from the protected internal storage and can be mounted as a
filesystem on a computer.*


On devices with multiple users (as described by `https://developer.android.com/reference/android/os/UserManager`),
each user has their own isolated shared storage. Applications only have
access to the shared storage for the user they're running as.


In devices with multiple shared/external storage directories, this
directory represents the primary storage that the user will interact
with. Access to secondary storage is available through
`https://developer.android.com/reference/android/content/Context#getExternalFilesDirs(java.lang.String)`,
`https://developer.android.com/reference/android/content/Context#getExternalCacheDirs()`, and
`https://developer.android.com/reference/android/content/Context#getExternalMediaDirs()`.


Applications should not directly use this top-level directory, in order
to avoid polluting the user's root namespace. Any files that are private
to the application should be placed in a directory returned by
`https://developer.android.com/reference/android/content/Context#getExternalFilesDir(java.lang.String)`, which the system will take care of deleting
if the application is uninstalled. Other shared files should be placed in
one of the directories returned by
`https://developer.android.com/reference/android/os/Environment#getExternalStoragePublicDirectory(java.lang.String)`.


Writing to this path requires the
`https://developer.android.com/reference/android/Manifest.permission#WRITE_EXTERNAL_STORAGE` permission,
and starting in `https://developer.android.com/reference/android/os/Build.VERSION_CODES#KITKAT`, read
access requires the
`https://developer.android.com/reference/android/Manifest.permission#READ_EXTERNAL_STORAGE` permission,
which is automatically granted if you hold the write permission.


Starting in `https://developer.android.com/reference/android/os/Build.VERSION_CODES#KITKAT`, if your
application only needs to store internal data, consider using
`https://developer.android.com/reference/android/content/Context#getExternalFilesDir(java.lang.String)`,
`https://developer.android.com/reference/android/content/Context#getExternalCacheDir()`, or
`https://developer.android.com/reference/android/content/Context#getExternalMediaDirs()`, which require no permissions to
read or write.


This path may change between platform versions, so applications should
only persist relative paths.


Here is an example of typical code to monitor the state of external
storage:


```
BroadcastReceiver mExternalStorageReceiver;
boolean mExternalStorageAvailable = false;
boolean mExternalStorageWriteable = false;

void updateExternalStorageState() {
    String state = Environment.getExternalStorageState();
    if (Environment.MEDIA_MOUNTED.equals(state)) {
        mExternalStorageAvailable = mExternalStorageWriteable = true;
    } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
        mExternalStorageAvailable = true;
        mExternalStorageWriteable = false;
    } else {
        mExternalStorageAvailable = mExternalStorageWriteable = false;
    }
    handleExternalStorageState(mExternalStorageAvailable,
            mExternalStorageWriteable);
}

void startWatchingExternalStorage() {
    mExternalStorageReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            Log.i("test", "Storage: " + intent.getData());
            updateExternalStorageState();
        }
    };
    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_MEDIA_MOUNTED);
    filter.addAction(Intent.ACTION_MEDIA_REMOVED);
    registerReceiver(mExternalStorageReceiver, filter);
    updateExternalStorageState();
}

void stopWatchingExternalStorage() {
    unregisterReceiver(mExternalStorageReceiver);
}
```


Note that alternatives such as `https://developer.android.com/reference/android/content/Context#getExternalFilesDir(java.lang.String)` or
`https://developer.android.com/reference/android/provider/MediaStore` offer better performance.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/io/File` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/os/Environment#getExternalStorageState()`
- `https://developer.android.com/reference/android/os/Environment#isExternalStorageRemovable()`

### getExternalStoragePublicDirectory

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static File getExternalStoragePublicDirectory (String type)
```

Get a top-level shared/external storage directory for placing files of a
particular type. This is where the user will typically place and manage
their own files, so you should be careful about what you put here to
ensure you don't erase their files or get in the way of their own
organization.


On devices with multiple users (as described by `https://developer.android.com/reference/android/os/UserManager`),
each user has their own isolated shared storage. Applications only have
access to the shared storage for the user they're running as.


Here is an example of typical code to manipulate a picture on the public
shared storage:

```
void createExternalStoragePublicPicture() {
    // Create a path where we will place our picture in the user's
    // public pictures directory.  Note that you should be careful about
    // what you place here, since the user often manages these files.  For
    // pictures and other media owned by the application, consider
    // Context.getExternalMediaDir().
    File path = Environment.getExternalStoragePublicDirectory(
            Environment.DIRECTORY_PICTURES);
    File file = new File(path, "DemoPicture.jpg");

    try {
        // Make sure the Pictures directory exists.
        path.mkdirs();

        // Very simple code to copy a picture from the application's
        // resource into the external file.  Note that this code does
        // no error checking, and assumes the picture is small (does not
        // try to copy it in chunks).  Note that if external storage is
        // not currently mounted this will silently fail.
        InputStream is = getResources().openRawResource(R.drawable.balloons);
        OutputStream os = new FileOutputStream(file);
        byte[] data = new byte[is.available()];
        is.read(data);
        os.write(data);
        is.close();
        os.close();

        // Tell the media scanner about the new file so that it is
        // immediately available to the user.
        MediaScannerConnection.scanFile(this,
                new String[] { file.toString() }, null,
                new MediaScannerConnection.OnScanCompletedListener() {
            public void onScanCompleted(String path, Uri uri) {
                Log.i("ExternalStorage", "Scanned " + path + ":");
                Log.i("ExternalStorage", "-> uri=" + uri);
            }
        });
    } catch (IOException e) {
        // Unable to create file, likely because external storage is
        // not currently mounted.
        Log.w("ExternalStorage", "Error writing " + file, e);
    }
}

void deleteExternalStoragePublicPicture() {
    // Create a path where we will place our picture in the user's
    // public pictures directory and delete the file.  If external
    // storage is not currently mounted this will fail.
    File path = Environment.getExternalStoragePublicDirectory(
            Environment.DIRECTORY_PICTURES);
    File file = new File(path, "DemoPicture.jpg");
    file.delete();
}

boolean hasExternalStoragePublicPicture() {
    // Create a path where we will place our picture in the user's
    // public pictures directory and check if the file exists.  If
    // external storage is not currently mounted this will think the
    // picture doesn't exist.
    File path = Environment.getExternalStoragePublicDirectory(
            Environment.DIRECTORY_PICTURES);
    File file = new File(path, "DemoPicture.jpg");
    return file.exists();
}
```


Note that alternatives such as `https://developer.android.com/reference/android/content/Context#getExternalFilesDir(java.lang.String)` or
`https://developer.android.com/reference/android/provider/MediaStore` offer better performance.

<br />

| Parameters ||
|---|---|
| `type` | `String`: The type of storage directory to return. Should be one of `https://developer.android.com/reference/android/os/Environment#DIRECTORY_MUSIC`, `https://developer.android.com/reference/android/os/Environment#DIRECTORY_PODCASTS`, `https://developer.android.com/reference/android/os/Environment#DIRECTORY_RINGTONES`, `https://developer.android.com/reference/android/os/Environment#DIRECTORY_ALARMS`, `https://developer.android.com/reference/android/os/Environment#DIRECTORY_NOTIFICATIONS`, `https://developer.android.com/reference/android/os/Environment#DIRECTORY_PICTURES`, `https://developer.android.com/reference/android/os/Environment#DIRECTORY_MOVIES`, `https://developer.android.com/reference/android/os/Environment#DIRECTORY_DOWNLOADS`, `https://developer.android.com/reference/android/os/Environment#DIRECTORY_DCIM`, or `https://developer.android.com/reference/android/os/Environment#DIRECTORY_DOCUMENTS`. May not be null. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/io/File` | Returns the File path for the directory. Note that this directory may not yet exist, so you must make sure it exists before using it such as with `https://developer.android.com/reference/java/io/File#mkdirs()`. <br /> |

### getExternalStorageState

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static String getExternalStorageState ()
```

Returns the current state of the primary shared/external storage media.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | one of `https://developer.android.com/reference/android/os/Environment#MEDIA_UNKNOWN`, `https://developer.android.com/reference/android/os/Environment#MEDIA_REMOVED`, `https://developer.android.com/reference/android/os/Environment#MEDIA_UNMOUNTED`, `https://developer.android.com/reference/android/os/Environment#MEDIA_CHECKING`, `https://developer.android.com/reference/android/os/Environment#MEDIA_NOFS`, `https://developer.android.com/reference/android/os/Environment#MEDIA_MOUNTED`, `https://developer.android.com/reference/android/os/Environment#MEDIA_MOUNTED_READ_ONLY`, `https://developer.android.com/reference/android/os/Environment#MEDIA_SHARED`, `https://developer.android.com/reference/android/os/Environment#MEDIA_BAD_REMOVAL`, or `https://developer.android.com/reference/android/os/Environment#MEDIA_UNMOUNTABLE`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/os/Environment#getExternalStorageDirectory()`

### getExternalStorageState

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static String getExternalStorageState (File path)
```

Returns the current state of the shared/external storage media at the
given path.

<br />

| Parameters ||
|---|---|
| `path` | `File` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | one of `https://developer.android.com/reference/android/os/Environment#MEDIA_UNKNOWN`, `https://developer.android.com/reference/android/os/Environment#MEDIA_REMOVED`, `https://developer.android.com/reference/android/os/Environment#MEDIA_UNMOUNTED`, `https://developer.android.com/reference/android/os/Environment#MEDIA_CHECKING`, `https://developer.android.com/reference/android/os/Environment#MEDIA_NOFS`, `https://developer.android.com/reference/android/os/Environment#MEDIA_MOUNTED`, `https://developer.android.com/reference/android/os/Environment#MEDIA_MOUNTED_READ_ONLY`, `https://developer.android.com/reference/android/os/Environment#MEDIA_SHARED`, `https://developer.android.com/reference/android/os/Environment#MEDIA_BAD_REMOVAL`, or `https://developer.android.com/reference/android/os/Environment#MEDIA_UNMOUNTABLE`. <br /> |

### getRootDirectory

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static File getRootDirectory ()
```

Return root of the "system" partition holding the core Android OS.
Always present and mounted read-only.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/io/File` | This value cannot be `null`. <br /> |

### getStorageDirectory

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static File getStorageDirectory ()
```

Return root directory where all external storage devices will be mounted.
For example, `https://developer.android.com/reference/android/os/Environment#getExternalStorageDirectory()` will appear under
this location.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/io/File` | This value cannot be `null`. <br /> |

### getStorageState

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level
21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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


**This method was deprecated
in API level 21.**   

use `https://developer.android.com/reference/android/os/Environment#getExternalStorageState(java.io.File)`

<br />

<br />

| Parameters ||
|---|---|
| `path` | `File` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | <br /> |

### isExternalStorageEmulated

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static boolean isExternalStorageEmulated ()
```

Returns whether the primary shared/external storage media is emulated.


The contents of emulated storage devices are backed by a private user
data partition, which means there is little benefit to apps storing data
here instead of the private directories returned by
`https://developer.android.com/reference/android/content/Context#getFilesDir()`, etc.


This returns true when emulated storage is backed by either internal
storage or an adopted storage device.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

**See also:**

- `https://developer.android.com/reference/android/app/admin/DevicePolicyManager#setStorageEncryption(android.content.ComponentName,%20boolean)`

### isExternalStorageEmulated

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static boolean isExternalStorageEmulated (File path)
```

Returns whether the shared/external storage media at the given path is
emulated.


The contents of emulated storage devices are backed by a private user
data partition, which means there is little benefit to apps storing data
here instead of the private directories returned by
`https://developer.android.com/reference/android/content/Context#getFilesDir()`, etc.


This returns true when emulated storage is backed by either internal
storage or an adopted storage device.

<br />

| Parameters ||
|---|---|
| `path` | `File`: This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the path is not a valid storage device. |

### isExternalStorageLegacy

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static boolean isExternalStorageLegacy (File path)
```

Returns whether the shared/external storage media is a
legacy view that includes files not owned by the app.


This value may be different from the value requested by
`requestLegacyExternalStorage` in the app's manifest, since an app
may inherit its legacy state based on when it was first installed, target sdk and other
factors.


Non-legacy apps can continue to discover and read media belonging to
other apps via `https://developer.android.com/reference/android/provider/MediaStore`.

<br />

| Parameters ||
|---|---|
| `path` | `File`: This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the path is not a valid storage device. |

### isExternalStorageLegacy

Added in [API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static boolean isExternalStorageLegacy ()
```

Returns whether the shared/external storage media is a
legacy view that includes files not owned by the app.


This value may be different from the value requested by
`requestLegacyExternalStorage` in the app's manifest, since an app
may inherit its legacy state based on when it was first installed, target sdk and other
factors.


Non-legacy apps can continue to discover and read media belonging to
other apps via `https://developer.android.com/reference/android/provider/MediaStore`.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### isExternalStorageManager

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static boolean isExternalStorageManager ()
```

Returns whether the calling app has All Files Access on the primary shared/external storage
media.

Declaring the permission `https://developer.android.com/reference/android/Manifest.permission#MANAGE_EXTERNAL_STORAGE` isn't
enough to gain the access.

To request access, use
`https://developer.android.com/reference/android/provider/Settings#ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION`.

<br />

| Returns ||
|---|---|
| `boolean` | <br /> |

### isExternalStorageManager

Added in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static boolean isExternalStorageManager (File path)
```

Returns whether the calling app has All Files Access at the given `path`

Declaring the permission `https://developer.android.com/reference/android/Manifest.permission#MANAGE_EXTERNAL_STORAGE` isn't
enough to gain the access.

To request access, use
`https://developer.android.com/reference/android/provider/Settings#ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION`.

<br />

| Parameters ||
|---|---|
| `path` | `File`: This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | <br /> |

### isExternalStorageRemovable

Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static boolean isExternalStorageRemovable (File path)
```

Returns whether the shared/external storage media at the given path is
physically removable.

<br />

| Parameters ||
|---|---|
| `path` | `File`: This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | true if the storage device can be removed (such as an SD card), or false if the storage device is built in and cannot be physically removed. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the path is not a valid storage device. |

### isExternalStorageRemovable

Added in [API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static boolean isExternalStorageRemovable ()
```

Returns whether the primary shared/external storage media is physically
removable.

<br />

| Returns ||
|---|---|
| `boolean` | true if the storage device can be removed (such as an SD card), or false if the storage device is built in and cannot be physically removed. <br /> |