Language

MediaStore.RestoreFileFromTrash(ContentResolver, String, String) Method

Definition

Restores a file or directory from a trashed state.

[Android.Runtime.Register("restoreFileFromTrash", "(Landroid/content/ContentResolver;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;", "", ApiSince=37)]
[Android.Runtime.RequiresPermission("android.permission.MANAGE_EXTERNAL_STORAGE")]
public static string RestoreFileFromTrash(Android.Content.ContentResolver resolver, string path, string? targetPath);
[<Android.Runtime.Register("restoreFileFromTrash", "(Landroid/content/ContentResolver;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;", "", ApiSince=37)>]
[<Android.Runtime.RequiresPermission("android.permission.MANAGE_EXTERNAL_STORAGE")>]
static member RestoreFileFromTrash : Android.Content.ContentResolver * string * string -> string

Parameters

resolver
ContentResolver

The ContentResolver to use for the call.

path
String

The absolute path of the trashed file or directory to be restored. This path should be the path of the item as it exists in the trash.

targetPath
String

An optional absolute path where the item should be restored. If null, the item will be restored to its original location prior to being trashed.

Returns

The absolute path of the item after it has been restored.

Attributes

Remarks

Restores a file or directory from a trashed state.

The item will be restored from the system's trash to its original location by default. If the original parent directories do not exist, they will be created as part of the restoration process. Optionally, a new targetPath can be specified to restore the item to a different location. If the specified path refers to a trashed directory, all its trashed contents will also be restored. If restoring a file would create a name conflict with an existing file, the system resolves this by appending a numerical suffix. For example, if image.jpeg exists, the restored file will be named image (1).jpeg.

Apps using this API must declare the Manifest.permission.MANAGE_EXTERNAL_STORAGE permission in their manifest and be granted it by the user.

Android reference for android.provider.MediaStore.restoreFileFromTrash.

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