我想使用google drive api从谷歌驱动器下载文件,下载文件后我想将文件保存到我的SD卡中。
我已经获得了我想要下载的资源ID。
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.i(TAG, "in onActivityResult() - triggered on pressing Select");
switch (requestCode) {
case REQUEST_CODE_SELECT:
if (resultCode == RESULT_OK) {
/*get the selected item's ID*/
DriveId driveId = (DriveId) data.getParcelableExtra(
OpenFileActivityBuilder.EXTRA_RESPONSE_DRIVE_ID);//this extra contains the drive id of the selected file
Log.i(TAG, "Selected folder's ID: " + driveId.encodeToString());
Log.i(TAG, "Selected folder's Resource ID: " + driveId.getResourceId());
Toast.makeText(getApplicationContext(),driveId.encodeToString()+":"+driveId.getResourceId() , Toast.LENGTH_LONG).show();
}
finish();
break;
case REQUEST_CODE_RESOLUTION:
if (resultCode == RESULT_OK) {
Log.i(TAG, "in onActivityResult() - resolving connection, connecting...");
googleApiClient.connect();
}
break;
default:
super.onActivityResult(requestCode, resultCode, data);
break;
}
}
现在我不知道如何使用该文件的资源ID下载文件,然后保存到SD卡。 我已经搜索了很多谷歌,但无法得到适当的解决方案。 有没有人可以帮我解决这个问题?