I am making an app which works with google drive.
I need to get a list of ALL files inside a folder, but it seems that it isnt possible: when I call listFiles method
It would take me long time to re-run your example, but I may have a few points to get you ahead.
First, since there is no DELETE functionality in Google Drive Android API yet, you are probably referring to the "remove" action in the web Drive interface. The status Metadata.isTrashed() does not reflect the status correctly as discussed here. And using requestSync() did not help. But I let this issue go since I expect them to fix it with the implementation of DELETE in GDAA. More on DELETE can be found here.
Second, I use the "await" version of the calls in my test environment (wrapped in AsyncTask) to test things. It is much easier to step through. I have experienced some "weird" behavior once a while, but could not pinpoint it. Fixed it by clearing the Google Play Services cache.
Third, there is a Google Api Client wrapper class GooApiClnt in this code (at the bottom) that seems to produce stable results - you may try it. You may test the 'findAll'(i.e. DriveApi.query) versions instead of 'listAll'(i.e. listChildren) since it allows you to filter the TRASHED state upfront. BTW, I noticed that you're not logging the Metadata.isTrashed() status in your example. It would give a better view of what files were deleted. But again, it would only confirm the sync latency issues.
The last, minor issue - and I don't know if it wasn't fixed on the GDAA level already - the release/closing of the of the 'getMetadataBuffer'. It was causing resource leaks in my code. Again, see the Github code referenced above, grep 'mdb.close()'.
Happy coding and good luck
I've tried this approach and I've also found that not all files are returned. Unfortunately, this behaviour is intentional =(
I quote from the documentation:
"The Google Drive Android API currently only supports drive.file and drive.appfolder"
drive.file (Drive.SCOPE_FILE) means: "Per-file access to files created or opened by the app"
"This means that only files which a user has opened or created with your application can be matched by a query"
See:
https://developers.google.com/drive/android/auth
https://developers.google.com/drive/android/queries