bimal chawla bimal chawla - 20 days ago 7
Android Question

How to delete file from Google Drive

I am using android-demos for implementing Google Drive integration in android. I successfully created a file in google drive. Now i want to delete that newly created file. I found the reference for this through https://developers.google.com/drive/v2/reference/files/delete Now files() method in this link is not found in Drive.

private static void deleteFile(Drive service, String fileId) {
try {
service.files().delete(fileId).execute();
} catch (IOException e) {
System.out.println("An error occurred: " + e);
}
}


Now please tell me how to delete file from Google Drive. I did research on this but found no solution. Some says use previous api of Google Drive. But that is obsolete now. Now Goole uses V2 for Drive.

Answer

Last time I checked, there is no delete in GDAA. See How to delete a file on google drive using Google Drive Android API

You can either wait for it to be implemented, or use the REST API https://developers.google.com/drive/v2/reference/files/delete

I suspect you are confusing two different APIs. GDAA is a purely local API, ie. your app is communicating with the Android Drive app. With the REST API, your app is talking over http to the Google Drive servers. Your app can use either, or a mixture of both (although you need to be pretty desparate to do that).