ContextWrapper.GetExternalMediaDirs Method

Definition

Caution

deprecated

Returns absolute paths to application-specific directories on all external storage devices where the application can place media files.

[Android.Runtime.Register("getExternalMediaDirs", "()[Ljava/io/File;", "GetGetExternalMediaDirsHandler")]
[System.Obsolete("deprecated")]
public override Java.IO.File[]? GetExternalMediaDirs();
[<Android.Runtime.Register("getExternalMediaDirs", "()[Ljava/io/File;", "GetGetExternalMediaDirsHandler")>]
[<System.Obsolete("deprecated")>]
override this.GetExternalMediaDirs : unit -> Java.IO.File[]

Returns

File[]

This method is deprecated. These directories still exist and are scanned, but developers are encouraged to migrate to inserting content into a MediaStore collection directly, as any app can contribute new media to MediaStore with no permissions required, starting in Build.VERSION_CODES.Q . Returns absolute paths to application-specific directories on all shared/external storage devices where the application can place media files. These files are scanned and made available to other apps through MediaStore . This is like getExternalFilesDirs(String) in that these files will be deleted when the application is uninstalled, however there are some important differences: Shared storage may not always be available, since removable media can be ejected by the user. Media state can be checked using Environment.getExternalStorageState(File) . There is no security enforced with these files. For example, any application holding Manifest.permission.WRITE_EXTERNAL_STORAGE can write to these files. Shared storage devices returned here are considered a stable part of the device, including physical media slots under a protective cover. The returned paths do not include transient devices, such as USB flash drives connected to handheld devices. An application may store data on any or all of the returned devices. For example, an app may choose to store large files on the device with the most available space, as measured by StatFs . No additional permissions are required for the calling app to read or write files under the returned path. Write access outside of these paths on secondary external storage devices is not available. The returned paths may change over time if different shared storage media is inserted, so only relative paths should be persisted. Returns File[] the absolute paths to application-specific directories. Some individual paths may be null if that shared storage is not currently available.

Attributes

Remarks

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Java documentation for android.content.ContextWrapper.getExternalMediaDirs().

Applies to