title: How to sync Google Spreadsheet in Android app and read rows from it
body: <p>I have one Spreadsheet file in my Google Drive which i want to sync from an Android Application. After a successful sync I have some search criteria in my apps, I want results based on this criteria from the file which I sync. I am doing this for the first time and not getting good resources to start with.</p>
  
  <p><strong>1) How to sync Google Drive file in Android App?</strong></p>
  
  <p><strong>2) How to retrieve particular data from the Spreadsheet which i have synced?</strong></p>
  
  <p><strong>Note</strong> - I am also confused between <strong>Google Docs API &amp; Google Drive SDK</strong>. </p>
  
  <p>What to use in my app? </p>
  
  <p>I have only one file to sync every time, not all the files. And the file is open to all with a private key.</p>
  
  <p><strong>I have implemented some code but it's not working. Below is my spreadsheet public url which i want to sync in my android app.</strong></p>
  
  <p>I am following steps from <a href="https://developers.google.com/google-apps/spreadsheets/" rel="nofollow">here</a>.</p>
  
  <p><a href="https://docs.google.com/spreadsheet/pub?key=0AlJeYFlqqMqrdGxOaHh3czVocmEtRlFsTDNiWno4VWc&amp;output=html" rel="nofollow">My Test Spreadsheet URL</a></p>
  
  <pre><code>try {
      String USERNAME = "xxxxx";
      String PASSWORD = "xxxxx";
  
      SpreadsheetService service =
          new SpreadsheetService("Testing");
      service.setUserCredentials(USERNAME, PASSWORD);
      // TODO: Authorize the service object for a specific user (see other sections)
  
      // Define the URL to request.  This should never change.
      URL SPREADSHEET_FEED_URL = new URL(
              "https://spreadsheets.google.com/feeds/spreadsheets/private/full");
  
      // Make a request to the API and get all spreadsheets.
      SpreadsheetFeed feed = service.getFeed(SPREADSHEET_FEED_URL,
              SpreadsheetFeed.class);
      List&lt;SpreadsheetEntry&gt; spreadsheets = feed.getEntries();
  
      if (spreadsheets.size() == 0) {
          // TODO: There were no spreadsheets, act accordingly.
      }
  
      // TODO: Choose a spreadsheet more intelligently based on your
      // app's needs.
      SpreadsheetEntry spreadsheet = spreadsheets.get(0);
      System.out.println(spreadsheet.getTitle().getPlainText());
  
      // Make a request to the API to fetch information about all
      // worksheets in the spreadsheet.
      List&lt;WorksheetEntry&gt; worksheets = spreadsheet.getWorksheets();
  
      // Iterate through each worksheet in the spreadsheet.
      for (WorksheetEntry worksheet : worksheets) {
          // Get the worksheet's title, row count, and column count.
          String title = worksheet.getTitle().getPlainText();
          int rowCount = worksheet.getRowCount();
          int colCount = worksheet.getColCount();
  
          // Print the fetched information to the screen for this worksheet.
          System.out.println("\t" + title + "- rows:" + rowCount + " cols: " + colCount);
      }
  } catch (Exception e) {
      e.printStackTrace();
  }
  </code></pre>