writing to Google Drive spreadsheet

10,006

Based on the comments we exchanged:

you looked at: Android - Google Spreadsheet Api which mentions 3 items:
Google Drive Api : https://developers.google.com/drive/
is for creating a spreadsheet. you might not need that if you are using an existing spreadsheet.

Google Spreadsheet Api: https://developers.google.com/google-apps/spreadsheets/
reads/writes to the spreadsheet

Google APi java client: http://code.google.com/p/google-api-java-client/
Wraps the api in a library for easy usage. Otherwise use the raw https calls directly.

For authentication you will need oauth2. Look at the samples for doing a google+ button login in android.
https://developers.google.com/+/mobile/android/sign-in
Once you have that going with the correct scopes (spreadsheets and maybe drive), that library will give you the "access token" you need to call the spreadsheets client library.

Share:
10,006
Ofek Agmon
Author by

Ofek Agmon

Updated on June 08, 2022

Comments

  • Ofek Agmon
    Ofek Agmon almost 2 years

    I read tons about the Google Drive API, Google Sheets API, and others, but with all the versions changing all the time I didn't understand what I should use...

    I have a android app, and all I want to do it to write text to a existing Google Drive spreadsheet.

    Example: Just have a edittext where I can put text and put it in a specific cell in the spreadsheet.

    The spreadsheet is in a folder that is shared with some people, and I want the user to enter a mail address and than (after I make sure that the folder is shared with him) can write to the spreadsheets in the folder.

    Also retrieving text from the spreadsheets is needed.

    Does anybody have any experience doing this in android??

    thanks!

    • Zig Mandel
      Zig Mandel over 9 years
      There is only one spreadsheets api (v3) and hasnt changed in at least 3 years. What you mean by "many versions"?
    • Ofek Agmon
      Ofek Agmon over 9 years
      thanks for your answer! the thing is I saw that people said that its needed 3 API's (in this question - stackoverflow.com/questions/13838963/…) and I can't figure out which ones I need and for what. if you have any experience working with this I would be happy for a code sample or explanation for what each API provides. thanks!
    • Zig Mandel
      Zig Mandel over 9 years
      I do have experience with that particular api. In that link, the 3rd one there is a library, not an API. The 2nd one (Google Spreadsheet Api) is the one you need. The 1st one (Google Drive Api) you only need if you need to create a spreadsheet, but there are some workarrounds for that like having the user create it manually. See developers.google.com/google-apps/spreadsheets/…
    • Ofek Agmon
      Ofek Agmon over 9 years
      thanks a lot! one more thing, do I need the oauth 2.0 in order to use the Google Spreadsheet Api? I read that i need it, but the example of how to actually preform the OAuth 2.0 in the google site is not clear.. I have registered my app and have a CLIENT ID in the google console. how do I do the OAuth 2.0 after that? thanks!
    • Zig Mandel
      Zig Mandel over 9 years
      There are answers in s.o. about that i think. If not please make a new question. There are google examples out there. You need the oauth2 3-legged flow which is all taken care by some methods in the client library you listed in the other s.o or in android itself by using google+ signin (see the android examples for that).
    • Ofek Agmon
      Ofek Agmon over 9 years
      so the Google APIs Client Library for Java is only used for the OAuth 2.0 process? after that its all Google Spreadsheet API? is there any others uses for the Lirary?
    • Zig Mandel
      Zig Mandel over 9 years
      To call the spreadsheet api, unless you want to call the api directly with https calls. Please see samples first, this questions is getting too generic.
    • Ofek Agmon
      Ofek Agmon over 9 years
      Okay I will thnaks a lot! last thing I wanna make sure. in the Google Spreadsheet API page (developers.google.com/google-apps/spreadsheets) they mention the GData client library. is it the same as the Google APIs Client Library? which is better for the Spreadsheet API?
    • Ofek Agmon
      Ofek Agmon over 9 years
      they only have the OAuth 2.0 part in .NET in the Spreasheet API page.. not in java
    • Zig Mandel
      Zig Mandel over 9 years
      I have actually never used the client libraries, only the raw https calls (both for spreadsheets and oauth2). Look at the examples provided for implementing google+ sign-in. Once you have that going, you will have the access token directly from the Google+ button client library.
    • Ofek Agmon
      Ofek Agmon over 9 years
      I tried using the google+ sign in button, but it requires a lot of not needed stuff like location and other... its not clear how to work with it.. can you please share some code about how you did the oauth 2.0 and the sheets HTTP calls? I would really appreciate it.. thanks
    • Zig Mandel
      Zig Mandel over 9 years
      Please open a new question sharing what you tried so far.
    • Ofek Agmon
      Ofek Agmon over 9 years
  • Ofek Agmon
    Ofek Agmon over 9 years
    thanks for the detailed answer. I'll try to use it and let you know if I have issues. thanks