I would like to get a list of files and folders in the root directory without having to sort through all the files. Is there a query that would do this?
Google drive v3 Reference the documentation helps to create DriveClient object.
Run this below method in the background thread(Android).
Note: Required Scope permission "DriveScopes.DRIVE"
protected String[] getListChildren(String parentId) throws Exception {
String[] children = null;
parentId = parentId == null ? "root" : parentId;
String fileQuery = "'" + parentId + "' in parents and trashed=false";
FileList files = driveService.files().list().setQ(fileQuery).execute();
List fileNames = new ArrayList();
for (File file : files.getFiles()) {
fileNames.add(file.getName());
}
children = fileNames.toArray(new String[0]);
return children;
}