public final class

Drive

extends Object
java.lang.Object
   ↳ com.google.android.gms.drive.Drive

Class Overview

The Drive API provides easy access to users' Google Drive contents. This API includes Activities to open or create files in users' Drives, as well as the ability to programmatically interact with contents, metadata, and the folder hierarchy.

Create a client DriveClient or DriveResourceClient to start interacting with Drive. The DriveClient provides access to basic Drive functionality, and the DriveResourceClient provides access to methods that interact with DriveResource objects.

Clients can be created with any of the following methods:

Be sure to pass in at least one of SCOPE_FILE or SCOPE_APPFOLDER when creating the GoogleSignInAccount.

Summary

Fields
public static final Api<Api.ApiOptions.NoOptions> API This field is deprecated. This is no longer necessary to provide.
public static final DriveApi DriveApi This field is deprecated. Gain access to the Drive API with one of the get*Client() methods instead.
public static final DrivePreferencesApi DrivePreferencesApi This field is deprecated. Gain access to the Drive API with one of the get*Client() methods instead.
public static final Scope SCOPE_APPFOLDER A Scope that gives 'drive.appfolder' access to a user's drive.
public static final Scope SCOPE_FILE A Scope that gives 'drive.file' access to a user's drive.
Public Methods
static DriveClient getDriveClient(Activity activity, GoogleSignInAccount account)
Creates a new instance of DriveClient for use in an Activity.
static DriveClient getDriveClient(Context context, GoogleSignInAccount account)
Creates a new instance of DriveClient for use in a non-Activity Context.
static DriveResourceClient getDriveResourceClient(Activity activity, GoogleSignInAccount account)
Creates a new instance of DriveResourceClient for use in an Activity.
static DriveResourceClient getDriveResourceClient(Context context, GoogleSignInAccount account)
Creates a new instance of DriveResourceClient for use in a non-Activity Context.
[Expand]
Inherited Methods
From class java.lang.Object

Fields

public static final Api<Api.ApiOptions.NoOptions> API

This field is deprecated.
This is no longer necessary to provide.

The API necessary to use Drive. Provide this as an API to addApi(Api).

public static final DriveApi DriveApi

This field is deprecated.
Gain access to the Drive API with one of the get*Client() methods instead.

The entry point for interacting with the Drive APIs which provides ways to access/update the files and folders in users Drive.

public static final DrivePreferencesApi DrivePreferencesApi

This field is deprecated.
Gain access to the Drive API with one of the get*Client() methods instead.

The entry point for interacting with the Drive APIs which provides ways to access/update Drive preferences.

public static final Scope SCOPE_APPFOLDER

A Scope that gives 'drive.appfolder' access to a user's drive. This scope gives access to files that have been created by the app in the App Folder.

This scope can be provided in requestScopes(Scope, Scope)

public static final Scope SCOPE_FILE

A Scope that gives 'drive.file' access to a user's drive. This scope give per-file access to files that have been created by, or specifically opened with the app.

This scope can be provided in requestScopes(Scope, Scope)

Public Methods

public static DriveClient getDriveClient (Activity activity, GoogleSignInAccount account)

Creates a new instance of DriveClient for use in an Activity. Error resolutions will be automatically launched from the provided Activity, displaying UI when necessary. This is the entry point for basic interactions with the Drive API.

Parameters
activity Activity
account GoogleSignInAccount
Returns
DriveClient

public static DriveClient getDriveClient (Context context, GoogleSignInAccount account)

Creates a new instance of DriveClient for use in a non-Activity Context. Error resolutions will be automatically launched from the provided Context, displaying system tray notifications when necessary. This is the entry point for basic interactions with the Drive API.

Parameters
context Context
account GoogleSignInAccount
Returns
DriveClient

public static DriveResourceClient getDriveResourceClient (Activity activity, GoogleSignInAccount account)

Creates a new instance of DriveResourceClient for use in an Activity. Error resolutions will be automatically launched from the provided Activity, displaying UI when necessary. This is the entry point for general management of all DriveResource objects with the Drive API.

Parameters
activity Activity
account GoogleSignInAccount
Returns
DriveResourceClient

public static DriveResourceClient getDriveResourceClient (Context context, GoogleSignInAccount account)

Creates a new instance of DriveResourceClient for use in a non-Activity Context. Error resolutions will be automatically launched from the provided Context, displaying system tray notifications when necessary. This is the entry point for general management of all DriveResource objects with the Drive API.

Parameters
context Context
account GoogleSignInAccount
Returns
DriveResourceClient