8
votes

Drive Quick-start App example works for only uploading files from Android Device to user account. I want to download the files from Gdrive to android app. any help will be appreciated.

I want exact reverse process of this Demo example https://developers.google.com/drive/quickstart-android (download it from Gdrive)

1
hello bro.... i am using same code from demo example Quickstart-android....but i have error with com.google.android.gms.drive.DriveApi.DriveContentsResult import from google play services lib...can you help me so i can use tyhis given codeDinesh R Rajput

1 Answers

5
votes

There are two steps to download file contents from Drive. First, retrieve the file's metadata and a downloadUrl for the file:

// retrieve metadata
File file = drive.files().get(fileId).execute();

And, make an authenticated request to the downloadUrl:

// download contents a
GenericUrl url = new GenericUrl(file.getDownloadUrl());
HttpResponse response = drive.getRequestFactory().buildGetRequest(url).execute();
String contents = new Scanner(response.getContent()).useDelimiter("\\A").next();