I'm using a Google Drive folder to backup some info from my app. I don't use App Folder since I want the user to be able to upload files to that same folder (for example, to upload a backup obtained by somebody else).
The code I use is the following:
Query query = new Query.Builder()
.addFilter(Filters.eq(SearchableField.TITLE, backupName))
.build();
DriveApi.MetadataBufferResult result =
mDriveFolder
.queryChildren(mGoogleApiClient, query)
.await();
if (result == null || !result.getStatus().isSuccess()) {
return null;
}
MetadataBuffer buffer = result.getMetadataBuffer();
if (buffer.getCount() == 0) {
buffer.close();
return null;
}
Metadata m = buffer.get(0); //get first
This way, I can find the backup file only if it was uploaded by my app through the backup function. If I upload to my Drive a file from my Desktop, or create a new document just for testing purposes, it is not found. (and from Drive I can correctly see all the files, either from my app or not, and I am the owner).
So, I tried to list and log all the folder contents:
DriveApi.MetadataBufferResult result = mDriveFolder.listChildren(mGoogleApiClient).await();
if (result == null || !result.getStatus().isSuccess()) {
return null;
}
MetadataBuffer buffer = result.getMetadataBuffer();
for(Metadata m: buffer){
Log.d(TAG, m.getTitle()+" - "+m.getOriginalFilename());
}
and only the files uploaded by my app are logged.
So, how can I get every content of my folder from the app, irrespective of its source? Am I missing something?