Introduction to the Google Drive Android API

The Drive Android API is a native API that conforms to standard Android best practices and coding conventions. It is an improvement over the generated client API, simplifying many common tasks associated with using the Drive service on mobile devices. The API automatically handles previously complex tasks such as offline access and syncing files. This allows you to read and write files as if Drive were a local file system.

The Drive Android API also significantly reduces the installed size of Drive-enabled apps. Because the API is part of the Google Play services client library, you no longer need to compile your app using the Google APIs Client Library for Java in order to access the Drive service.

For more information on what the Google Drive Android API can do for your application, check out our official launch video.


This documentation assumes you are familiar with Android development and object-oriented programming concepts. You should also be familiar with Google Drive from a user's point of view.

API Overview

The Google Drive Android API provides abstractions for managing file content and metadata. Files are represented by the DriveFile interface; folders by the DriveFolder interface. Both share a common superinterface, DriveResource, which contains a DriveId. This is the unique identifier for all files and folders.

The API also includes a package for querying for files based on metadata attributes, such as the title.

Resource metadata

Metadata for resources are encapsulated in the Metadata class that contains all details about a file or folder including the title, the MIME type, and whether the file is editable, starred or trashed. The Metadata is fetched for a DriveResource by calling the DriveResource.getMetadata method.

The Metadata may be set or changed when creating or updating a file using a MetadataChangeSet and setting the appropriate values, then calling the DriveResource.updateMetadata method.

For more information, see Working with Metadata.


Files can be fetched programmatically using the DriveApi.getFile method or by allowing the user to select a file using a file selector activity created with the OpenFileActivityBuilder. The file contains a reference to the contents of the file, encapsulated in the DriveContents class, which provides access to read and write the underlying data. Access the contents using the method.

For more information, see Working with File Contents.


Folders have additional helpers which simplify various operations. These include creating a file or folder inside a folder DriveFolder.createFile, DriveFolder.createFolder and listing or querying the children of a folder DriveFolder.listChildren, DriveFolder.queryChildren.

For more information, see Working with Folders.

Activity Builders

Activity builders are two helper classes that implement UI components to simplify common tasks associated with opening and creating files.

CreateFileActivityBuilder helps you quickly create a file, set its initial folder, title, contents, and metadata. The class also implements a simple UI that allows a user to specify the file's title and destination folder. For more information, see Creating Files.

OpenFileActivityBuilder helps you easily open a file selected by the user. The class displays a simple UI to let the user navigate and select from a list of files that match the specified MIME types. When you invoke the class, you specify an initial folder where the user's navigation begins. You can also specify a preferred set of MIME types for the file list.


Queries allow you to search for specific files or folders based on their metadata attributes, such as the title. Queries are represented by the Query class and can be constructed using the Query.Builder class.

For more information, see Querying for Files.

Developer Resources

In addition to the sample code bundled with the Google Play services SDK, many more examples can be found at the official Google Drive GitHub repository.

Enviar comentarios sobre…

Drive API for Android
Drive API for Android