title: Android: How to get the uploaded file URL in Google Drive
body: <p>I can upload files to my Google Drive account but I need to get the URL (link) of the file to use it later?
  example: <a href="https://docs.google.com/file/d/oB-xxxxxxxxxxx/edit" rel="nofollow">https://docs.google.com/file/d/oB-xxxxxxxxxxx/edit</a></p>
  
  <p>This is my method to upload file to Google Drive:</p>
  
  <pre><code>private void saveFileToDrive()
  {
      Thread t = new Thread(new Runnable() {
          @Override
          public void run() {
              try {
                  // Create URI from real path
                  String path;
                  path = "/sdcard/DCIM/Camera/a.png";
                  mFileUri = Uri.fromFile(new java.io.File(path));
  
                  ContentResolver cR = UploadActivity.this.getContentResolver();
  
                  // File's binary content
                  java.io.File fileContent = new java.io.File(mFileUri.getPath());
                  FileContent mediaContent = new FileContent(cR.getType(mFileUri), fileContent);
  
                  showToast("Selected " + mFileUri.getPath() + "to upload");
  
                  // File's meta data. 
                  File body = new File();
                  body.setTitle(fileContent.getName());
                  body.setMimeType(cR.getType(mFileUri));                 
                  com.google.api.services.drive.Drive.Files f1 = mService.files();
                  com.google.api.services.drive.Drive.Files.Insert i1 = f1.insert(body, mediaContent);
                  File file = i1.execute();
  
                  if (file != null) 
                  {
                      showToast("Uploaded: " + file.getTitle());
                  }
              } catch (UserRecoverableAuthIOException e) {
                  startActivityForResult(e.getIntent(), REQUEST_AUTHORIZATION);
              } catch (IOException e) {
                  e.printStackTrace();
                  showToast("Transfer ERROR: " + e.toString());
              }
          }
      });
      t.start();
  }
  </code></pre>