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.
The Google Drive Android API provides abstractions for managing file content
and metadata. Files are represented by the
folders by the
DriveFolder interface. Both share a common
DriveId. This is the
unique identifier for all files and folders.
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
The Metadata may be set or changed when creating or updating a file using
MetadataChangeSet and setting
the appropriate values, then calling the
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
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
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.createFolder and listing or querying the children of a folder
For more information, see Working with Folders.
Activity builders are two helper classes that implement UI components to simplify common tasks associated with opening and creating files.
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
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
For more information, see Querying for Files.