public interface

# DriveApi

com.google.android.gms.drive.DriveApi

## Class Overview

The main entry point for interacting with Drive. This class provides methods for obtaining a reference to a file or folder, or querying across the entire Drive.

## Summary

Nested Classes
interface | DriveApi.DriveContentsResult | Result that contains a `DriveContents`.
interface | DriveApi.DriveIdResult | Result that contains a `DriveId`.
interface | DriveApi.MetadataBufferResult | Result that contains a `MetadataBuffer`.

Public Methods
abstract PendingResult<Status> | cancelPendingActions(GoogleApiClient apiClient, List<String> trackingTags) This method is deprecated. This API is being discontinued.
abstract PendingResult<DriveApi.DriveIdResult> | fetchDriveId(GoogleApiClient apiClient, String resourceId) Retrieves a `DriveId` object that can be used in further drive api operations (e.g.
abstract DriveFolder | getAppFolder(GoogleApiClient apiClient) Returns a `DriveFolder` object that can be used to interact with the App Folder.
abstract DriveFile | getFile(GoogleApiClient apiClient, DriveId id) This method is deprecated. Use `asDriveFile()` instead
abstract DriveFolder | getFolder(GoogleApiClient apiClient, DriveId id) This method is deprecated. Use `asDriveFolder()` instead
abstract DriveFolder | getRootFolder(GoogleApiClient apiClient) Returns a `DriveFolder` object that can be used to interact with the root folder.
abstract PendingResult<BooleanResult> | isAutobackupEnabled(GoogleApiClient apiClient) This method is deprecated. With no replacement
abstract CreateFileActivityBuilder | newCreateFileActivityBuilder() Creates a builder for a Create File activity where a user can select a file name and destination for a new binary file in their Drive with the contents and additional metadata provided in the builder.
abstract PendingResult<DriveApi.DriveContentsResult> | newDriveContents(GoogleApiClient apiClient) Retrieves a new `DriveContents` instance that can be used to provide initial contents for a new file.
abstract OpenFileActivityBuilder | newOpenFileActivityBuilder() Creates a builder for an Open File activity that allows user selection of a Drive file.
abstract PendingResult<DriveApi.MetadataBufferResult> | query(GoogleApiClient apiClient, Query query) Retrieves a collection of metadata for the files and folders that match the specified query.
abstract PendingResult<Status> | requestSync(GoogleApiClient apiClient) Requests synchronization with the server to download any metadata changes that occurred since the last sync with the server.

## Public Methods

#### public abstract PendingResult<Status> cancelPendingActions (GoogleApiClient apiClient, List<String> trackingTags)

This method is deprecated.
This API is being discontinued.

Requests a canceling of the actions identified by the specified tags.

This method does not guarantee that the requested actions will be canceled as some of the actions may be in a state where they can't be canceled anymore.

Only actions originating from this application and from the account set on this client may be canceled by this call.

It is recommended using this method with actions that were performed with `ExecutionOptions` requesting completion notifications, so that for any canceled action a `CompletionEvent` with status `STATUS_CANCELED` is delivered to the application. This way the application may know which actions were actually canceled.

##### Parameters

trackingTags | the list of tracking tags that identify the actions that should be canceled.

##### Returns

- A successful status only indicates that the API received the cancel request, but not that all the requested actions were actually canceled. `CompletionEvent` may be used to track the canceled actions.

#### public abstract PendingResult<DriveApi.DriveIdResult> fetchDriveId (GoogleApiClient apiClient, String resourceId)

Retrieves a `DriveId` object that can be used in further drive api operations (e.g. getFile, getFolder). An error result will be returned if the given resource ID does not exist.

##### Parameters

apiClient | The `GoogleApiClient` to service the call.
resourceId | The Drive resource id for the DriveId to retrieve.

##### Returns

- A PendingResult which can be used to retrieve the DriveId object.

#### public abstract DriveFolder getAppFolder (GoogleApiClient apiClient)

Returns a `DriveFolder` object that can be used to interact with the App Folder.

The App Folder is a special folder that is only accessible by your application. Its content is hidden from the user and from other apps. Despite being hidden from the user, the App Folder is stored on the user's Drive and therefore uses the user's Drive storage quota.

The App Folder can be used to store configuration files, temporary files, or any other types of files that belong to the user but should not be tampered with.

The AppData scope is required to access this folder. If the app does not have `SCOPE_APPFOLDER` it will return null.

See the App Folder developer guide for more information.

This method will return synchronously, and is safe to invoke from the UI thread.

##### Parameters

apiClient | The `GoogleApiClient` to service the call. The client must be connected using `connect()` before invoking this method.

##### Throws

IllegalStateException | if this method is called before the client is connected.

#### public abstract DriveFile getFile (GoogleApiClient apiClient, DriveId id)

This method is deprecated.
Use `asDriveFile()` instead

Retrieves a `DriveFile` object that can be used to interact with the file specified by the provided `DriveId`.

##### Parameters

apiClient | The `GoogleApiClient` to service the call. The client must be connected using `connect()` before invoking this method.

#### public abstract DriveFolder getFolder (GoogleApiClient apiClient, DriveId id)

This method is deprecated.
Use `asDriveFolder()` instead

Retrieves a `DriveFolder` object that can be used to interact with the folder specified by the provided `DriveId`.

##### Parameters

apiClient | The `GoogleApiClient` to service the call. The client must be connected using `connect()` before invoking this method.

#### public abstract DriveFolder getRootFolder (GoogleApiClient apiClient)

Returns a `DriveFolder` object that can be used to interact with the root folder. This method will return synchronously, and is safe to invoke from the UI thread.

`SCOPE_FILE` is required to access this folder. If the app only has `SCOPE_APPFOLDER` it will return null.

##### Parameters

apiClient | The `GoogleApiClient` to service the call. The client must be connected using `connect()` before invoking this method.

##### Throws

IllegalStateException | if this method is called before the client is connected.

#### public abstract PendingResult<BooleanResult> isAutobackupEnabled (GoogleApiClient apiClient)

This method is deprecated.
With no replacement

Indicates whether the user's photos are being backed up by other Google Services. Apps that provide automatic photo backup should check this setting before uploading photos to Drive to avoid duplicate backups.

##### Parameters

apiClient | The `GoogleApiClient` to service the call. The client must be connected before invoking this method.

#### public abstract CreateFileActivityBuilder newCreateFileActivityBuilder ()

Creates a builder for a Create File activity where a user can select a file name and destination for a new binary file in their Drive with the contents and additional metadata provided in the builder.

This method requires authorization with at least one of the following scopes: `SCOPE_FILE`. Otherwise, a `RuntimeException` will be thrown when the builder is built.

#### public abstract PendingResult<DriveApi.DriveContentsResult> newDriveContents (GoogleApiClient apiClient)

Retrieves a new `DriveContents` instance that can be used to provide initial contents for a new file. The returned contents will be in `MODE_WRITE_ONLY` and can be used to write the initial contents through the file APIs provided in `DriveContents`.

To be persisted, the contents must be saved by being passed as initial contents to `createFile(GoogleApiClient, MetadataChangeSet, DriveContents)` or `setInitialDriveContents(DriveContents)`.

To discard the contents without saving them, invoke `discard(GoogleApiClient)`.

##### Parameters

apiClient | The `GoogleApiClient` to service the call. The client must be connected using `connect()` before invoking this method.

##### Returns

- A PendingResult which can be used to retrieve the Contents object.

#### public abstract OpenFileActivityBuilder newOpenFileActivityBuilder ()

Creates a builder for an Open File activity that allows user selection of a Drive file. Upon completion, the result Intent will contain the `DriveId` for the selected file. This activity will authorize the requesting app to interact with the selected file.

This method requires authorization with at least one of the following scopes: `SCOPE_FILE`. Otherwise, a `RuntimeException` will be thrown when the builder is built.

#### public abstract PendingResult<DriveApi.MetadataBufferResult> query (GoogleApiClient apiClient, Query query)

Retrieves a collection of metadata for the files and folders that match the specified query.

##### Parameters

apiClient | The `GoogleApiClient` to service the call.
query | The query that will restrict the contents of the result set.

##### Returns

- A PendingResult which can be used to retrieve the result set. Be sure to call `release()` when you're done with the result.

#### public abstract PendingResult<Status> requestSync (GoogleApiClient apiClient)

Requests synchronization with the server to download any metadata changes that occurred since the last sync with the server.

Typically you'd call this method when the user asks to refresh their list of files. Waiting on the `PendingResult` and then performing a query will return fresh results.

In order to avoid excessive load on the device and the server, sync requests are rate limited. In this case, the operation will fail with `DRIVE_RATE_LIMIT_EXCEEDED` status, which indicates that a sync already happened quite recently so there is no need for another sync. The operation will succeed when reattempted after a sufficient backoff duration.

##### Parameters

apiClient | The `GoogleApiClient` to service the call. The client must be connected before invoking this method.

##### Returns

- a `PendingResult` that returns when synchronization has completed.