Share via


Environment.GetExternalStoragePublicDirectory(String) Method

Definition

Get a top-level shared/external storage directory for placing files of a particular type.

[Android.Runtime.Register("getExternalStoragePublicDirectory", "(Ljava/lang/String;)Ljava/io/File;", "")]
public static Java.IO.File? GetExternalStoragePublicDirectory (string? type);
[<Android.Runtime.Register("getExternalStoragePublicDirectory", "(Ljava/lang/String;)Ljava/io/File;", "")>]
static member GetExternalStoragePublicDirectory : string -> Java.IO.File

Parameters

type
String

The type of storage directory to return. Should be one of #DIRECTORY_MUSIC, #DIRECTORY_PODCASTS, #DIRECTORY_RINGTONES, #DIRECTORY_ALARMS, #DIRECTORY_NOTIFICATIONS, #DIRECTORY_PICTURES, #DIRECTORY_MOVIES, #DIRECTORY_DOWNLOADS, #DIRECTORY_DCIM, or #DIRECTORY_DOCUMENTS. May not be null.

Returns

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 File#mkdirs File.mkdirs().

Attributes

Remarks

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 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:

{

Java documentation for android.os.Environment.getExternalStoragePublicDirectory(java.lang.String).

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.

Applies to