Summary: Nested Classes | Methods | [Expand All]
public interface

# DriveResource

com.google.android.gms.drive.DriveResource

Known Indirect Subclasses DriveFile, DriveFolder
DriveFile | A file in Drive.
DriveFolder | A folder in Drive.

## Class Overview

A Resource represents a file or folder in Drive.

## Summary

Nested Classes
interface | DriveResource.MetadataResult | Result that is returned in response to metadata requests.

Public Methods
abstract PendingResult<Status> | addChangeListener(GoogleApiClient apiClient, ChangeListener listener) Adds a new listener for changes on this resource.
abstract PendingResult<Status> | addChangeSubscription(GoogleApiClient apiClient) Adds a change subscription for this resource that will deliver events to the application event service.
abstract PendingResult<Status> | delete(GoogleApiClient apiClient) Permanently deletes this resource, bypassing trash.
abstract DriveId | getDriveId() Returns the DriveId that uniquely identifies this resource.
abstract PendingResult<DriveResource.MetadataResult> | getMetadata(GoogleApiClient apiClient) Retrieves the Metadata associated with this resource.
abstract PendingResult<DriveApi.MetadataBufferResult> | listParents(GoogleApiClient apiClient) Retrieves a collection of metadata for all of the parents of this resource that the calling app has been authorized to view.
abstract PendingResult<Status> | removeChangeListener(GoogleApiClient apiClient, ChangeListener listener) Removes a listener for changes on this resource that was previously added by `addChangeListener(GoogleApiClient, ChangeListener)`.
abstract PendingResult<Status> | removeChangeSubscription(GoogleApiClient apiClient) Removes any existing change subscription for this resource.
abstract PendingResult<Status> | setParents(GoogleApiClient apiClient, Set<DriveId> parentIds) Sets the parents of this resource.
abstract PendingResult<Status> | trash(GoogleApiClient apiClient) Moves the resource to trash.
abstract PendingResult<Status> | untrash(GoogleApiClient apiClient) Moves the resource out of the trash.
abstract PendingResult<DriveResource.MetadataResult> | updateMetadata(GoogleApiClient apiClient, MetadataChangeSet changeSet) Updates the Metadata that is associated with this resource with the changes described in the `MetadataChangeSet`.

## Public Methods

#### public abstract PendingResult<Status> addChangeListener (GoogleApiClient apiClient, ChangeListener listener)

Adds a new listener for changes on this resource. The listener will remain active for the duration of the current `GoogleApiClient` connection or until the `removeChangeListener(GoogleApiClient, ChangeListener)` method is called with the same listener argument.

##### See Also

- `ChangeEvent`
- `DriveEvent`

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

Adds a change subscription for this resource that will deliver events to the application event service. The event service class implementation should contain an implementation of `ChangeListener` and be exported in the application manifest. The subscription is persistent until the next device reboot and will be active until the `removeChangeSubscription(GoogleApiClient)` method is called on the same resource.

##### See Also

- `ChangeEvent`
- `DriveEventService`

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

Permanently deletes this resource, bypassing trash. The user must be the owner. If the resource is a folder, the app must have access to all descendants of the folder.

For user visible files, we recommend using the `trash(GoogleApiClient)` method instead to give users the opportunity to restore files they have accidentally removed.

Delete must be used for files in the App Folder as they cannot be trashed, see `getAppFolder(GoogleApiClient)`.

##### Parameters

apiClient | The `GoogleApiClient` to service the call.

##### Returns

- A PendingResult which can be used to verify the success of the operation.

#### public abstract DriveId getDriveId ()

Returns the DriveId that uniquely identifies this resource.

#### public abstract PendingResult<DriveResource.MetadataResult> getMetadata (GoogleApiClient apiClient)

Retrieves the Metadata associated with this resource.

##### Parameters

apiClient | The `GoogleApiClient` to service the call.

##### Returns

- A PendingResult which can be used to retrieve the Metadata when it is available.

#### public abstract PendingResult<DriveApi.MetadataBufferResult> listParents (GoogleApiClient apiClient)

Retrieves a collection of metadata for all of the parents of this resource that the calling app has been authorized to view.

##### Parameters

apiClient | The `GoogleApiClient` to service the call.

##### Returns

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

#### public abstract PendingResult<Status> removeChangeListener (GoogleApiClient apiClient, ChangeListener listener)

Removes a listener for changes on this resource that was previously added by `addChangeListener(GoogleApiClient, ChangeListener)`.

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

Removes any existing change subscription for this resource.

#### public abstract PendingResult<Status> setParents (GoogleApiClient apiClient, Set<DriveId> parentIds)

Sets the parents of this resource. If successful, the resource parent set will be changed to the one specified in the parameter. The existing parent set will be overwritten. The caller must make sure that the set contains all intended parents of the resource, including existing parents that should remain as parents.

All parents must be folders.

If this resource is in the App Folder or in one of its subfolders, all parents must also belong to the App Folder or one of its subfolders.

If this resource is outside the App Folder every parent must also be outside the App Folder.

##### Parameters

apiClient | The `GoogleApiClient` to service the call.
parentIds | The set of parents (can be empty) to move the item to. Do NOT modify the set after calling this method.

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

Moves the resource to trash. The user must be the owner. If the resource is a folder, the app must have access to all descendants of the folder.

Resources inside the app folder cannot be trashed.

##### Parameters

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

##### Returns

- A PendingResult which can be used to verify the success of the operation.

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

Moves the resource out of the trash. The user must be the owner. If the resource is a folder, the app must have access to all descendants of the folder.

Resources inside the app folder cannot be untrashed (they cannot be trashed in the first place).

##### Parameters

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

##### Returns

- A PendingResult which can be used to verify the success of the operation.

#### public abstract PendingResult<DriveResource.MetadataResult> updateMetadata (GoogleApiClient apiClient, MetadataChangeSet changeSet)

Updates the Metadata that is associated with this resource with the changes described in the `MetadataChangeSet`.

Note that the user must have edit access to update certain metadata fields (see `MetadataChangeSet.Builder`). Also, the metadata of the root folder cannot be updated.

##### Parameters

apiClient | The `GoogleApiClient` to service the call. The client must be connected when this method is invoked.
changeSet | The set of changes that will be applied to the Metadata. Only include the specific fields that should be updated.

##### Returns

- A PendingResult which will return the updated Metadata when it is available.