title: How do I upload file to google drive from android
body: <p>I have spend more then one day but not getting any working solution which provide me uploading / downloading files to <code>Google Drive</code>. </p>
  
  <p>I have tried <code>Google Play Service</code> but i didn't find any method which upload / download files.</p>
  
  <p>I try Google Client libraries but there are some method are not resolved.</p>
  
  <p>such as :</p>
  
  <pre><code>service.files().insert(body, mediaContent).execute();
  errors: The method execute() is undefined for the type Drive.Files.Insert
  </code></pre>
  
  <p>I can upload image through below code but this is Google Drive file up loader. I can only upload one only one file at a time.</p>
  
  <pre><code>mFile = new java.io.File(fileList.get(i));
                  Log.i(TAG, "Creating new contents.");
                  Drive.DriveApi.newContents(mGoogleApiClient).addResultCallback(
                          new OnNewContentsCallback() {
  
                              @Override
                              public void onNewContents(ContentsResult result) {
  
                                  if (!result.getStatus().isSuccess()) {
                                      Log.i(TAG, "Failed to create new contents.");
                                      return;
                                  }
  
                                  Log.i(TAG, "New contents created.");
  
                                  OutputStream outputStream = result
                                          .getContents().getOutputStream();
  
                                  byte[] byteStream = new byte[(int) mFile
                                          .length()];
                                  try {
                                      outputStream.write(byteStream);
                                  } catch (IOException e1) {
                                      Log.i(TAG, "Unable to write file contents.");
                                  }
  
                                  MetadataChangeSet metadataChangeSet = new MetadataChangeSet.Builder()
                                          .setMimeType("image/jpeg")
                                          .setMimeType("text/html")
                                          .setTitle("Android Photo.png").build();
                                  // Create an intent for the file chooser, and
                                  // start it.
                                  IntentSender intentSender = Drive.DriveApi
                                          .newCreateFileActivityBuilder()
                                          .setInitialMetadata(metadataChangeSet)
                                          .setInitialContents(
                                                  result.getContents())
                                          .build(mGoogleApiClient);
                                  try {
                                      mActivity.startIntentSenderForResult(
                                              intentSender, REQUEST_CODE_CREATOR,
                                              null, 0, 0, 0);
                                      publishProgress(1);
                                  } catch (SendIntentException e) {
                                      Log.i(TAG, "Failed to launch file chooser.");
                                      publishProgress(0);
                                  }
                              }
                          });
  </code></pre>
  
  <p>But still fighting for downloading a file.</p>