title: Find a Google Drive Sheet By Name Using API 4 In Android
body: <p>I followed the "Android Quickstart" below.</p>
  
  <p><a href="https://developers.google.com/sheets/api/quickstart/android" rel="noreferrer">https://developers.google.com/sheets/api/quickstart/android</a></p>
  
  <p>Works great.</p>
  
  <p>But the sample hard-codes a spreadsheetId to an existing spreadsheet. </p>
  
  <pre><code>String spreadsheetId = "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms";
  </code></pre>
  
  <p><strong>I need to be able to find an existing spreadsheet, <em>by name,</em> and store the id</strong> (for later use).</p>
  
  <p>I'd like to do something like this:</p>
  
  <pre><code>private com.google.api.services.sheets.v4.Sheets sheetsService = null;
  
  
  HttpTransport transport = AndroidHttp.newCompatibleTransport();
  JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
  
  sheetsService = new com.google.api.services.sheets.v4.Sheets.Builder(
          transport, jsonFactory, credential)
          .setApplicationName("My Application Name")
          .build();
  
  String spreadsheetId = null;
  List&lt;Spreadsheet&gt; allSpreadsheets = sheetsService.spreadsheets().getAListOfAllSpreadsheets;
  for (Spreadsheet spreadsheet : allSpreadsheets) {
      if (spreadsheet.getName().equals("My Sheet")){
          // found!
          spreadsheetId = spreadsheet.getId();
      }
  }
  </code></pre>
  
  <p>Much thanks in advance!</p>