Guest1997 Guest1997 - 1 year ago 207
Android Question

Google Drive Rest API v3 - how to move a file to the trash?

The Google Drive Rest API v3 has a Drive.Files.Delete method, but that permanently deletes the file.How do i move the file to the trash?

I looked at the docs for updating file metadata, and i tried to do this, but it doesn't seem to work:

File file = new File();
driveService.files().update(f.getId(), file).execute();

Answer Source

I don't see any error with your code on how to move a file to trash wherein you'll use files.update with {'trashed':true}.

Sample code in this thread:

The solution is to create an empty File setting only the new values:

File newContent = new File();
service.files().update(fileId, newContent).execute();

I have tried this in Google Drive Try it! and successfully moved the file to trash.

Just make sure that the File refers to and it is not

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download