Delete or trash files and folders

You can move a DriveResource, such
as file or folder, to or from the user's trash with the
DriveResourceClient.trash
and
DriveResourceClient.untrash
methods. These
can be used to trash or untrash files or folders owned by the currently
authenticated user. DriveResource objects that are shared with but not owned
by the currently authenticated user cannot be trashed or untrashed.

Note:AppFolder resources cannot be trashed
or untrashed. Delete
must be used to remove AppFolder resources.

If the target of the trash/untrash operation is a folder, all descendants of
that folder are similarly trashed or untrashed. If your application does not
have permission to all of the descendants of the target folder, the entire
operation is canceled. If the folder contains items not owned by the current
user, the folder is still trashed or untrashed, but items not owned by the
current user are unaffected and remain in their current state.

Check if a file is in the trash

You can determine if a file is already in the trash or can be trashed by
retrieving its metadata. There are three methods
for determining a file's status:

Returns true if the resource is owned by the currently authenticated user
and is not in the AppFolder. The resource may
still be untrashable if one of its descendents is not accessible by your
application or is in the AppFolder.

Delete a file

Deleting a file bypasses trash and permanently deletes the file. A file can be
deleted using the DriveResourceClient.delete
method. To delete a file, the authenticated user must be the owner of the file
and your app must have access to the file. If the resource being deleted is a
folder, your app must also have access to all descendants of the folder.

Note: Delete is intended for use with application data. While delete can be used
for deleting user data, it is not recommended since delete cannot be undone.
Use trash for removing user data.