0

I want to implement Google Drive upload/download txt file to my Android app using Google Play Services, but I don't find a right way to do it.

In dropbox is very easy:

File file = new File("working-draft.txt");
FileInputStream inputStream = new FileInputStream(file);
Entry response = mDBApi.putFile("/magnum-opus.txt", inputStream,
                            file.length(), null, null);
Log.i("DbExampleLog", "The uploaded file's rev is: " + response.rev);

But for Google Drive with Google Play Services I have not found a simple way like that. Do you know how to?

By the way, I would like to use my own credentials (google service account) instead an user account, what is the way to implement it with Google Play Services?

Thanks in advance

user1904954
  • 63
  • 1
  • 7

1 Answers1

0

Take a look here, it does everything you've mentioned. I don't know about the 'simple' requirement, though. Or go through the official DEMO code here. But it is definitely not a 'two-liner' endeavor.

seanpj
  • 6,735
  • 2
  • 33
  • 54
  • Thank you so much. I want to ask you about to implement a service account with this code, I saw here:[hardcoded credentials](http://stackoverflow.com/questions/15497888/how-to-use-google-drive-sdk-in-android-project-with-hardcoded-credentials) how to implement with other libraries, and it use GoogleCredential to do the auth, with this key method: .setServiceAccountId(G_SERVICE_EMAIL) .setServiceAccountPrivateKeyFromP12File(PKC_12_FILE) To not require login. But I don't know how to implement this in your code, because there is no Google Service Account method for GoogleApiClient builder. – user1904954 May 17 '14 at 19:38
  • Unfortunately, I don't know anything about credentials. – seanpj May 18 '14 at 00:02