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?
This code will display all files and folder of your ROOT DIRECTORY. just copy and paste this code and you will get all your root's file and folder.
List result = new ArrayList();
Files.List request = null;
try {
request = mService.files().list();
FileList files = request.setQ("'root' in parents and trashed=false").execute();
result.addAll(files.getItems());
request.setPageToken(files.getNextPageToken());
}
catch (IOException e)
{
System.out.println("An error occurred: " + e);
request.setPageToken(null);
}
//Print out all the files and folder of root Directory
for(File f:result)
{
System.out.println("recvd data are: "+f.getTitle());
}