Monday, August 24, 2015

Google Drive APIs

Drive Android API is a native API that conforms to the standard best practices and coding conventions. 
It is improvement over the generated client API, simplifying many common tasks associated with using Drive service on mobile devices.
The API automatically handles the complex tasks such as Synching and offline access. 

These APIs are part of Google play services API. 

Below is an API Overview for this API set 

Files are represented using the DriveFile interface. folder are by DriveFolder. Both share common super interface DriveResource, which contains DriveId. 
The DriveId is the unique Identifier for all the files and folders. 

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

Resource Metadata : MetaData for resource is 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 DriveResourece.updateMetaData method. 

Files: Files can be fetched programmatically by 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, encapsultated in the DriveContents class, which provides access to read and write the 
underlying the data.

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

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

CreateFileActivityBuilder help to quickly create a file, set inside a folder title, contents and set meta data. 

OpenFileActivityBuilder help to easily open a file selected by the user. This class displays a UI to let the user navigate and select from a list of files that match the specified MIME types. 

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

References:

No comments:

Post a Comment