0

I've searched on Google but I don't find anything that can really help me.
I've tested some codes.

One test is this: Get list of files from a specific folder in google drive but it show only 3 files/folders (in // md gives you the file info, I've added md.getTitle()) or nothing, I don't know why.

Then I've tried with this: https://github.com/googledrive/android-demos/blob/master/app/src/main/java/com/google/android/gms/drive/sample/demo/ListFilesInFolderActivity.java, changed the last method. I've used the MetadataBufferResult result so:

MetadataBuffer metadataBuffer = result.getMetadataBuffer();
Log.d("DRIVE","size: "+metadataBuffer.getCount());
metadataBuffer.release();

And the "size" is like the previus test: it is 3, 0 or 1, but there are more folder/files.

How can I list all files in a folder? Do you give me an example?

Kara
  • 6,115
  • 16
  • 50
  • 57
Simone Sessa
  • 795
  • 1
  • 12
  • 35

1 Answers1

0

If you simply want to get all direct children of a particular folder, you can use DriveFolder.listChildren as discussed in Working with Folders documentation.

However, to list all files of a specific folder, it would be better to use Files: list method with q parameter to filter your search as given in Search for Files. You can send a request with the following format:

GET https://www.googleapis.com/drive/v2/files?q="'<FOLDER_ID>' in parents"

This sample request returns all files of the specified ID and also includes files with trashed=true in the results. Use the trashed=false query parameter to filter these from the results.

Important Note: Every request your application sends to the Drive API must include an authorization token as discussed in the Drive API documentation.

Here are some related SO posts which might also help:

Community
  • 1
  • 1
Teyam
  • 7,686
  • 3
  • 15
  • 22
  • I've try with this https://developers.google.com/drive/v3/reference/files/list#try-it but what I can put in "q" field? – Simone Sessa Oct 12 '16 at 19:44