我正在尝试从google drive app文件夹下载文件,为此我需要驱动器ID(我想是这样)但是使用驱动器ID我使用下面的代码,我一直得到文件/文件夹未找到错误
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);
}
});
当我尝试获取驱动器ID时,我当然做错了什么。尝试了我的运气与getResourceID(),但同样的错误。
答案 0 :(得分:0)
你仔细检查了你的SCOPE吗?代码应如下所示:
GoogleApiClient mGAC = new GoogleApiClient.Builder(act)
.addApi(Drive.API)
.addScope(Drive.SCOPE_FILE)
.addScope(Drive.SCOPE_APPFOLDER)
.addConnectionCallbacks( ... )
.addOnConnectionFailedListener( ...)
.setAccountName(email)
.build();
祝你好运