StorageVolume.CreateAccessIntent(String) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Builds an intent to give access to a standard storage directory or entire volume after obtaining the user's approval.
[Android.Runtime.Register("createAccessIntent", "(Ljava/lang/String;)Landroid/content/Intent;", "", ApiSince=24)]
public Android.Content.Intent? CreateAccessIntent (string? directoryName);
[<Android.Runtime.Register("createAccessIntent", "(Ljava/lang/String;)Landroid/content/Intent;", "", ApiSince=24)>]
member this.CreateAccessIntent : string -> Android.Content.Intent
Parameters
- directoryName
- String
must be one of Environment#DIRECTORY_MUSIC
,
Environment#DIRECTORY_PODCASTS
, Environment#DIRECTORY_RINGTONES
,
Environment#DIRECTORY_ALARMS
, Environment#DIRECTORY_NOTIFICATIONS
,
Environment#DIRECTORY_PICTURES
, Environment#DIRECTORY_MOVIES
,
Environment#DIRECTORY_DOWNLOADS
, Environment#DIRECTORY_DCIM
, or
Environment#DIRECTORY_DOCUMENTS
, or null
to request access to the
entire volume.
Returns
intent to request access, or null
if the requested directory is invalid for
that volume.
- Attributes
Remarks
Builds an intent to give access to a standard storage directory or entire volume after obtaining the user's approval.
When invoked, the system will ask the user to grant access to the requested directory (and its descendants). The result of the request will be returned to the activity through the onActivityResult
method.
To gain access to descendants (child, grandchild, etc) documents, use DocumentsContract#buildDocumentUriUsingTree(Uri, String)
, or DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)
with the returned URI.
If your application only needs to store internal data, consider using Context#getExternalFilesDirs(String) Context.getExternalFilesDirs
, Context#getExternalCacheDirs()
, or Context#getExternalMediaDirs()
, which require no permissions to read or write.
Access to the entire volume is only available for non-primary volumes (for the primary volume, apps can use the android.Manifest.permission#READ_EXTERNAL_STORAGE
and android.Manifest.permission#WRITE_EXTERNAL_STORAGE
permissions) and should be used with caution, since users are more likely to deny access when asked for entire volume access rather than specific directories.
This member is deprecated. Callers should migrate to using Intent#ACTION_OPEN_DOCUMENT_TREE
instead. Launching this Intent
on devices running android.os.Build.VERSION_CODES#Q
or higher, will immediately finish with a result code of android.app.Activity#RESULT_CANCELED
.
Java documentation for android.os.storage.StorageVolume.createAccessIntent(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.