The Google Drive API includes a special hidden folder that your app can use to store application specific data.
Here's the tutorial: Storing Application Data
I insert the file into the hidden folder with this method:
private static File insertFileInApplicationDataFolder(Drive service, String title, String description,
String mimeType, String filename) {
// File's metadata.
File body = new File();
body.setTitle(title);
body.setDescription(description);
body.setMimeType(mimeType);
body.setParents(Arrays.asList(new ParentReference().setId("appfolder")));
// File's content.
java.io.File fileContent = new java.io.File(filename);
FileContent mediaContent = new FileContent(mimeType, fileContent);
try {
File file = service.files().insert(body, mediaContent).execute();
return file;
} catch (IOException e) {
System.out.println("An error occured: " + e);
return null;
}
}
Now, I want to delete all files that are into the folder.
I tried with service.files().get("appfolder").execute().clear();
, but it doesn't work. The files remain there.