I am trying to download a file from google drive app folder and for that I need the drive id (I think so) but with the drive id I get using the code below, I keep getting the file/folder not found error.
Drive.DriveApi.getAppFolder(mGoogleApiClientDrive)
.listChildren(mGoogleApiClientDrive)
.setResultCallback(new ResultCallback<DriveApi.MetadataBufferResult>() {
@Override
public void onResult(DriveApi.MetadataBufferResult result) {
if (!result.getStatus().isSuccess()) {
Toast.makeText(GoogleSignIn.this, "Unable to get any result", Toast.LENGTH_SHORT).show();
}
MetadataBuffer mdb = result.getMetadataBuffer();
String ID = mdb.get(0).getDriveId().encodeToString();
// Method for downloading data from google drive
downloadContent(ID);
}
});
Certainly I am doing something wrong when trying to fetch the drive id. Tried my luck with getResourceID() too but again with the same error.
Did you double-check your SCOPE? The code should look like this:
GoogleApiClient mGAC = new GoogleApiClient.Builder(act)
.addApi(Drive.API)
.addScope(Drive.SCOPE_FILE)
.addScope(Drive.SCOPE_APPFOLDER)
.addConnectionCallbacks( ... )
.addOnConnectionFailedListener( ...)
.setAccountName(email)
.build();
Good Luck