title: Is there a replacement for the methods: Drive.getDriveClient(), Drive.getDriveResourceClient, ... from deprecated api?
body: <p>Deprecated methods in the code (below) made it possible to integrate the Google Drive Picker into the Android application.</p>
  
  <pre><code>import com.google.android.gms.drive.Drive; // deprecated
  import com.google.android.gms.drive.Drive; // deprecated
  import com.google.android.gms.drive.DriveClient; // deprecated
  import com.google.android.gms.drive.DriveFile; // deprecated
  import com.google.android.gms.drive.DriveId; // deprecated
  import com.google.android.gms.drive.DriveResourceClient; // deprecated
  import com.google.android.gms.drive.Metadata; // deprecated
  import com.google.android.gms.drive.OpenFileActivityOptions; // deprecated
  import com.google.android.gms.drive.query.Filters; // deprecated
  import com.google.android.gms.drive.query.SearchableField; // deprecated
  
      // ...
  
      /**
       * Handles high-level drive functions like sync
       */
      private DriveClient mDriveClient; // deprecated
      private Drive mDriveService; // deprecated
  
      /**
       * Handle access to Drive resources/files.
       */
      private DriveResourceClient mDriveResourceClient; // deprecated
  
      // ...
  
      /**
       * Continues the sign-in process, initializing the Drive clients with the current
       * user's account.
       */
      private void initializeDriveClient(GoogleSignInAccount signInAccount) {
          mDriveClient = Drive.getDriveClient(getApplicationContext(), signInAccount);
          mDriveResourceClient = Drive.getDriveResourceClient(getApplicationContext(), signInAccount);
          // ...
      }
  
      /**
       * Prompts the user to select a folder using OpenFileActivity.
       *
       * @param openOptions Filter that should be applied to the selection
       * @return Task that resolves with the selected item's ID.
       */
      private Task&lt;DriveId&gt; pickItem(OpenFileActivityOptions openOptions) {
          mOpenItemTaskSource = new TaskCompletionSource&lt;&gt;();
          getDriveClient()
                  .newOpenFileActivityIntentSender(openOptions)
                  .continueWith((Continuation&lt;IntentSender, Void&gt;) task -&gt; {
                      startIntentSenderForResult(
                              task.getResult(), REQUEST_CODE_OPEN_ITEM,
                              null, 0, 0, 0);
                      return null;
                  });
          return mOpenItemTaskSource.getTask();
      }
  
      /**
       * Handles resolution callbacks.
       */
      @Override
      protected void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
          switch (requestCode) {
              case REQUEST_CODE_OPEN_ITEM:
                  if (resultCode == RESULT_OK) {
                      DriveId driveId = data.getParcelableExtra(
                              OpenFileActivityOptions.EXTRA_RESPONSE_DRIVE_ID);
                      mOpenItemTaskSource.setResult(driveId);
                      fileId = driveId.getResourceId();
                  } else {
                      mOpenItemTaskSource.setException(
                              new RuntimeException("Unable to open file")
                      );
                  }
                  break;
                  }
          super.onActivityResult(requestCode, resultCode, data);
      }
  
      /**
       * To retrieve the metadata of a file.
       */
      private void retrieveMetadata(final DriveFile file) {
          Task&lt;Metadata&gt; getMetadataTask = getDriveResourceClient().getMetadata(file);
          getMetadataTask
                  .addOnSuccessListener(this,
                          (Metadata metadata) -&gt; {
                              showMessage(getString(
                                      R.string.metadata_retrieved, metadata.getTitle()));
                              fileName = metadata.getTitle();
                              sendDownloadAuthData();
                              finish();
                          })
                  .addOnFailureListener(this, e -&gt; {
                      Log.e(TAG, "Unable to retrieve metadata", e);
                      showMessage(getString(R.string.read_failed));
                      finish();
                  });
      }
  
      protected DriveResourceClient getDriveResourceClient() {
          return mDriveResourceClient;
      }
  
      protected DriveClient getDriveClient() {
          return mDriveClient;
      }
  </code></pre>
  
  <p>In the new Drive Api v3, I didn’t find the methods that allow to preserve the functionality of the program. In one of the examples from Google suggests using SAF. But SAF works through android.net.Uri. It allows to get the name of the file, but it does not provide for the file ID.</p>
  
  <pre><code>    /**
       * Opens the file at the {@code uri} returned by a Storage Access 
         Framework {@link Intent}
       * created by {@link #createFilePickerIntent()} using the given 
         {@code contentResolver}.
       */
      public Task&lt;String&gt; getCurrentFileName(
              ContentResolver contentResolver, Uri uri) {
          return Tasks.call(mExecutor, () -&gt; {
              // Retrieve the document's display name from its metadata.
              String currentName = "";
              try (Cursor cursor = contentResolver
                      .query(uri, null, null, null, null)) {
                  if (cursor != null &amp;&amp; cursor.moveToFirst()) {
                      Log.d(TAG, "cursor.getColumnCount(): " + 
                       cursor.getColumnCount());
                      for (int i = 0; i &lt; cursor.getColumnCount(); i++) {
                          Log.d(TAG, i + " - " + cursor.getString(i) + 
                        "\n");
                      }
                      int nameIndex = 
                    cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
                      currentName = cursor.getString(nameIndex);
                  } else {
                      throw new IOException("Empty cursor returned for 
                 file.");
                  }
              }
  
              return currentName;
          });
      }
  </code></pre>
  
  <p>The file ID is needed for the method:</p>
  
  <pre><code>void downloadFile(String fileId) {
          try {
              java.io.File targetFile = new java.io.File(FULL_PATH_MD);
              mFileOutputStream = new FileOutputStream(targetFile);
  
              mDriveService.files()
                      .export(fileId, "text/csv")
                      .executeMediaAndDownloadTo(mFileOutputStream);
          } catch (Exception e) {
              e.printStackTrace();
          } finally {
              Utils.closeQuietly(mFileOutputStream, true);
          }
      }
  </code></pre>
  
  <p>Additional information to the question on the link:
  <a href="https://stackoverflow.com/questions/56416007/how-to-migrate-to-drive-api-v3-and-get-file-id-for-files-export">How to migrate to Drive API v3 and get file ID for files.export?</a></p>
  
  <p>What can I replace the deprecated methods to preserve the functionality of the program? What do you advise?</p>