Reputation: 33
I followed this tutorial in my android app, and I can login, select, view file from my Google Drive account. How can I download a file to my cache folder when I know the DriveId of the file. I know I can obtain drivefile like this.
DriveFile driveFile = mFileId.asDriveFile();
Can I convert this driveFile to File. I tried to cast it, didn't work. In this link there is a method for downloading the file, but i can't find files() or executeMediaAndDownloadTo in my Drive driveService. Is this for an old version? I couldn't find anything useful on the internet for this.
Upvotes: 2
Views: 2584
Reputation: 35661
Try
DriveApi.DriveContentsResult result = id.asDriveFile()
.open(client, DriveFile.MODE_READ_ONLY, null).await();
check status is good with
result.getStatus().isSuccess()
then access the file with
result.getDriveContents().getInputStream()
client
is your GoogleApiClient
instance
Write the InputStream
to a File
if you want to create a copy of the file.
Upvotes: 3