title: How I can create and upload google spreadsheet using android app?
body: <p>I have spent too much time on this so I would like to ask about it. I want to create and upload google spreadsheet using android. I know that I should use <strong>Drive API</strong> to do this. I know how to create file using this API(even excel file) but when <strong>setMimeType</strong> is set to <strong>application/vnd.google-apps.spreadsheet</strong> I receive an error on the device: <strong>Error while trying to create the file.</strong></p>
  
  <pre><code>    @Override
  public void onConnected(Bundle connectionHint) {
      super.onConnected(connectionHint);
      // create new contents resource
      Drive.DriveApi.newDriveContents(getGoogleApiClient())
              .setResultCallback(driveContentsCallback);
  }
  
  final private ResultCallback&lt;DriveContentsResult&gt; driveContentsCallback = new
          ResultCallback&lt;DriveContentsResult&gt;() {
              @Override
              public void onResult(DriveContentsResult result) {
                  if (!result.getStatus().isSuccess()) {
                      showMessage("Error while trying to create new file contents");
                      return;
                  }
                  final DriveContents driveContents = result.getDriveContents();
  
                  // Perform I/O off the UI thread.
                  new Thread() {
                      @Override
                      public void run() {
                          // write content to DriveContents
                          OutputStream outputStream = driveContents.getOutputStream();
                          Writer writer = new OutputStreamWriter(outputStream);
                          try {
                              writer.write("Hello World!");
                              writer.write("Hello World!");
                              writer.close();
                          } catch (IOException e) {
                              Log.e(TAG, e.getMessage());
                          }
  
                          MetadataChangeSet changeSet = new MetadataChangeSet.Builder()
                                  .setTitle("Orders")
                                  .setMimeType("application/vnd.google-apps.spreadsheet")
                                  .setStarred(true).build();
  
  
  
                          // create a file on root folder
                          Drive.DriveApi.getRootFolder(getGoogleApiClient())
                                  .createFile(getGoogleApiClient(), changeSet, driveContents)
                                  .setResultCallback(fileCallback);
                      }
                  }.start();
              }
          };
  
  final private ResultCallback&lt;DriveFileResult&gt; fileCallback = new
          ResultCallback&lt;DriveFileResult&gt;() {
              @Override
              public void onResult(DriveFileResult result) {
                  if (!result.getStatus().isSuccess()) {
                      showMessage("Error while trying to create the file");
                      return;
                  }
                  showMessage("Created a file with content: " + result.getDriveFile().getDriveId());
                  storeId(result.getDriveFile().getDriveId());
                  kill_activity();
              }
          };v
  </code></pre>