7

My app asks users to select a Google Drive folder so that it can save files to the selected folder later.

Until now it used the folder picker UI of the Google Drive Android API, but now that is deprecated and shut down. The migration note suggests to use the Storage Access Framework (a.k.a SAF) in order to replace the File Picker UI that was previously available.

The problem is that when I am trying to use the ACTION_OPEN_DOCUMENT_TREE action to launch the SAF UI, Google Drive doesn't show up. Another Stackoverflow posts suggest that picking Google Drive folders is not supported with SAF, which is bizarre as it's a very essential and basic feature.

Is there any way to implement a folder picker UI for Google Drive without having to build it myself from scratch?

 val intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
 startActivityForResult(intent, 3);
Crocodile
  • 5,724
  • 11
  • 41
  • 67
  • I am not a Google Drive user, but the migration note says: "The Drive Android app must be installed for users to be able to select Drive files via SAF". Do you have the Drive app installed? – CommonsWare Mar 07 '20 at 17:28
  • Yes sure, I have the Google Drive app installed. – Crocodile Mar 07 '20 at 17:28
  • 2
    Just checking! Last I heard, they supported `ACTION_OPEN_DOCUMENT` (and perhaps `ACTION_CREATE_DOCUMENT`) but not `ACTION_OPEN_DOCUMENT_TREE`. If that's what you are seeing, then they haven't changed their stance, and their migration note is only relevant for picking content, not trees. There is nothing that you can do, on the client side, so somehow force Drive to support `ACTION_OPEN_DOCUMENT_TREE`. – CommonsWare Mar 07 '20 at 17:34
  • Thanks for checking. That is the answer I feared! – Crocodile Mar 07 '20 at 17:37
  • 3
    In principle, there is nothing stopping somebody from creating a Drive documents provider that *does* support trees, using the Drive REST API. A quick scan of the Play Store didn't turn up anything, but I didn't look all that hard. :-) If you found such an app, you could advise users to install and configure that, at which point your app would be able to use SAF. Otherwise, you are probably stuck using the REST API yourself. – CommonsWare Mar 07 '20 at 17:42

0 Answers0