다음을 통해 공유


Context.GetDir(String, FileCreationMode) Method

Definition

Retrieve, creating if needed, a new directory in which the application can place its own custom data files.

[Android.Runtime.Register("getDir", "(Ljava/lang/String;I)Ljava/io/File;", "GetGetDir_Ljava_lang_String_IHandler")]
public abstract Java.IO.File? GetDir (string? name, Android.Content.FileCreationMode mode);
[<Android.Runtime.Register("getDir", "(Ljava/lang/String;I)Ljava/io/File;", "GetGetDir_Ljava_lang_String_IHandler")>]
abstract member GetDir : string * Android.Content.FileCreationMode -> Java.IO.File

Parameters

name
String

Name of the directory to retrieve. This is a directory that is created as part of your application data.

mode
FileCreationMode

Operating mode.

Returns

A File object for the requested directory. The directory will have been created if it does not already exist.

Attributes

Remarks

Retrieve, creating if needed, a new directory in which the application can place its own custom data files. You can use the returned File object to create and access files in this directory. Note that files created through a File object will only be accessible by your own application; you can only set the mode of the entire directory, not of individual files.

The returned path may change over time if the calling app is moved to an adopted storage device, so only relative paths should be persisted.

Apps require no extra permissions to read or write to the returned path, since this path lives in their private storage.

Java documentation for android.content.Context.getDir(java.lang.String, int).

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

See also

  • <xref:Android.Content.Context.OpenFileOutput(System.String%2c+Android.Content.FileCreationMode)>