Search code examples
androidgoogle-drive-android-api

Google Drive API - Get folders list


I have some folders in Google Drive (lets assume, that I have them in the Root folder).

How can I parse them from Drive as folderName and driveId?

I'd like to do it with Google Drive API Google Drive API, not with REST.


Solution

  • You need to setup Google Drive API for Android in your project. Everything is in guides/documentation on Google Drive API site. Here is link to get started

    Then you will do like this:

    1. Get root folder by calling DriveApi.getRootFolder
    2. Get children of the root folder by calling method listChildren (Link to documentation) on folder returned in step 1
    3. Process result by getting Metadata from buffer
    4. Get file by calling DriveID object method asDriveFile() (Link to documentation)