Search for files (with conditions) in the Google Drive SDK using Java
google-drive-api, java
Solution
I found it. I think the Google Drive SDK documentation needs to be a little less ambiguous.
Files.List request = service.files().list().setQ("mimeType = 'application/vnd.google-apps.folder'");
Problem
I'm trying to search for files in the drive with Java, but I'm not sure how to set the conditions. The example given in the video tutorial is in Python. So, basically here is the method that will retrieve the List of files from the Drive: ``` private static List<File> retrieveAllFiles(Drive service) throws IOException { List<File> result = new ArrayList<File>(); Files.List request = service.files().list(); do { try { FileList files = request.execute(); result.addAll(files.getItems()); request.setPageToken(files.getNextPageToken()); } catch (IOException e) { System.out.println("An error occurred: " + e); request.setPageToken(null); } } while (request.getPageToken() != null && request.getPageToken().length() > 0); return result; } ``` Now, they mention here that the File.List method accepts the q parameter. How can I do that? When I try to set the parameter with examples like the given in the video where q = "title contains 'fruit'", it does not work. What am I doing wrong? Is the request.queue() used for this? Thanks