public interface

DriveFile

implements DriveResource
com.google.android.gms.drive.DriveFile

Class Overview

A file in Drive. This class provides access to the contents and metadata of the specified file. To retrieve a DriveFile from a known drive id, use getFile(GoogleApiClient, DriveId).

Summary

Nested Classes
interface DriveFile.DownloadProgressListener A listener that listens for progress events on an active contents download. 
Constants
int MODE_READ_ONLY A mode that opens the contents only for reading.
int MODE_READ_WRITE A mode that opens the contents only for writing.
int MODE_WRITE_ONLY A mode that opens the contents for reading and writing.
Public Methods
abstract PendingResult<Status> commitAndCloseContents(GoogleApiClient apiClient, Contents contents, MetadataChangeSet changeSet)
Closes the previously opened contents, updates the Metadata associated with this file, and commits any changes if the contents were open for write.
abstract PendingResult<Status> commitAndCloseContents(GoogleApiClient apiClient, Contents contents)
Closes the previously opened contents, and commits any changes if the contents were open for write.
abstract PendingResult<Status> discardContents(GoogleApiClient apiClient, Contents contents)
Closes the provided contents without saving the results.
abstract PendingResult<DriveApi.ContentsResult> openContents(GoogleApiClient apiClient, int mode, DriveFile.DownloadProgressListener listener)
Opens the contents that are associated with this file for read and/or write.
[Expand]
Inherited Methods
From interface com.google.android.gms.drive.DriveResource

Constants

public static final int MODE_READ_ONLY

A mode that opens the contents only for reading.

Constant Value: 268435456 (0x10000000)

public static final int MODE_READ_WRITE

A mode that opens the contents only for writing.

Constant Value: 805306368 (0x30000000)

public static final int MODE_WRITE_ONLY

A mode that opens the contents for reading and writing.

Constant Value: 536870912 (0x20000000)

Public Methods

public abstract PendingResult<Status> commitAndCloseContents (GoogleApiClient apiClient, Contents contents, MetadataChangeSet changeSet)

Closes the previously opened contents, updates the Metadata associated with this file, and commits any changes if the contents were open for write. After invoking this method, the contents are no longer valid. New contents should not be closed via this method. Instead, use them to create a new file via createFile(GoogleApiClient, MetadataChangeSet, Contents) or newCreateFileActivityBuilder().

Parameters
apiClient The GoogleApiClient to service the call. The client must be connected before invoking this method.
contents The contents that will be saved and closed.
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 can be used to verify the success of the operation.

public abstract PendingResult<Status> commitAndCloseContents (GoogleApiClient apiClient, Contents contents)

Closes the previously opened contents, and commits any changes if the contents were open for write. After invoking this method, the contents are no longer valid. New contents should not be closed via this method. Instead, use them to create a new file via createFile(GoogleApiClient, MetadataChangeSet, Contents) or newCreateFileActivityBuilder().

Parameters
apiClient The GoogleApiClient to service the call. The client must be connected before invoking this method.
contents The contents that will be saved and closed.
Returns
  • a PendingResult which can be used to verify the success of the operation.

public abstract PendingResult<Status> discardContents (GoogleApiClient apiClient, Contents contents)

Closes the provided contents without saving the results.

Parameters
apiClient The GoogleApiClient to service the call. The client must be connected before invoking this method.
contents The contents to discard.
Returns
  • a PendingResult which can be used to verify the success of the operation.

public abstract PendingResult<DriveApi.ContentsResult> openContents (GoogleApiClient apiClient, int mode, DriveFile.DownloadProgressListener listener)

Opens the contents that are associated with this file for read and/or write. The returned file is a temporary copy available only to this app. The contents are returned when they are available on the device in their entirety. To listen for progress, provide a DriveFile.DownloadProgressListener.

The contents must be closed via commitAndCloseContents(GoogleApiClient, Contents). If the contents are opened for write, invoking close will save the updates. Every open must be matched with a corresponding commitAndCloseContents(GoogleApiClient, Contents).

Note: to open the file in edit mode, the user must have edit access. See isEditable().

Parameters
apiClient The GoogleApiClient to service the call.
mode Describes the mode in which to open the file. Possible values are MODE_READ_ONLY, MODE_READ_WRITE and MODE_WRITE_ONLY.
listener An optional listener that will announce progress as the file is downloaded. If you don't care about progress, provide null.
Returns
  • a PendingResult which can be used to retrieve the Contents when they are available.