0

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?

seanpj
  • 6,735
  • 2
  • 33
  • 54
Ale
  • 235
  • 2
  • 11
  • 1
    Please see [this (SO 32760028) answer](http://stackoverflow.com/questions/32760028/get-all-folders-google-drive-api-on-android/32760777#32760777) – seanpj Sep 30 '15 at 12:29
  • `Drive.DriveApi.requestSync(mGoogleApiClient);` to request a sync with server. – M. Reza Nasirloo Jan 19 '16 at 21:43

1 Answers1

0

It is not possible with Google Drive SDK. You should use http-requests for it.

Ilya Tretyakov
  • 6,848
  • 3
  • 28
  • 45