7

Is there any way to start file picker for google drive in android app - to do something similar to this http://googleappsdeveloper.blogspot.com/2012/08/allowing-user-to-select-google-drive.html. I need to allow user to select files from google drive, so I can use their bytes in my application. Thanks.

seanpj
  • 6,735
  • 2
  • 33
  • 54
Mediha
  • 650
  • 2
  • 9
  • 24

2 Answers2

6

Yes, there is a file picker in the GDAA. The best place to see it's use is this demo, specifically the Intents section.

There are 2 methods in the demo you are interested in:

  1. the 'Pick a file with opener activity' ,
  2. and the 'Pick a folder with opener activity'

but they are essentially the same, differing only in the MIME TYPE filter specified here:

IntentSender intentSender = Drive.DriveApi.newOpenFileActivityBuilder()
 .setMimeType(new String[] { DriveFolder.MIME_TYPE })  // <--- FOLDER
 //.setMimeType(new String[] { "text/plain", "text/html" }) // <- TEXT FILES
 .build(getGoogleApiClient());

Good Luck

seanpj
  • 6,735
  • 2
  • 33
  • 54
  • go [here](https://github.com/googledrive/android-demos), find the 'Intents' section, click away... – seanpj Sep 30 '15 at 21:25
  • For this to work you must call this intent after the GoogleApiClient successfully connected (probably in the overridden onConnected(Bundle hints) method) – mikeLundquist Aug 10 '17 at 21:11
  • @seanpj is possible to pick a folder (not in app created) by default without Intent and using GDAA ? – flaviussn Oct 17 '17 at 11:07
  • 1
    The Drive Android API is deprecated as of December 6, 2018 and will be turned down on December 6, 2019. https://developers.google.com/drive/android/deprecation – OlegKrikun Feb 21 '19 at 15:54
2

There is an api for this. I think this google's documentation should help https://developers.google.com/drive/android/queries. I'm not sure on how you want to go about it.

  • 1
    Note that as of December 2018, the API in this link is now in the process of being deprecated by Google. – shagberg Dec 16 '18 at 02:19