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 asDriveFile()
.
Nested Class Summary
interface | DriveFile.DownloadProgressListener | A listener for progress events on an active contents download. |
Constant Summary
int | MODE_READ_ONLY | A mode that opens the contents only for reading. |
int | MODE_READ_WRITE | A mode that opens the contents for reading and writing. |
int | MODE_WRITE_ONLY | A mode that opens the contents only for writing. |
Public Method Summary
abstract PendingResult<DriveApi.DriveContentsResult> |
open(GoogleApiClient apiClient, int mode, DriveFile.DownloadProgressListener listener)
Opens the
DriveContents that are associated with this file for read and/or write. |
Inherited Method Summary
Constants
public static final int MODE_READ_ONLY
A mode that opens the contents only for reading.
public static final int MODE_READ_WRITE
A mode that opens the contents for reading and writing.
public static final int MODE_WRITE_ONLY
A mode that opens the contents only for writing.
Public Methods
public abstract PendingResult<DriveApi.DriveContentsResult> open (GoogleApiClient apiClient, int mode, DriveFile.DownloadProgressListener listener)
Opens the DriveContents
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 must be closed
via commit(GoogleApiClient, MetadataChangeSet)
or discard(GoogleApiClient)
.
Availability
The contents are returned when they are available on the device in their entirety. Content is
returned from the cache if it is available and up to date, otherwise it will be downloaded
from the server. To listen for download progress, provide a DriveFile.DownloadProgressListener
.
Note: If the download fails, e.g. due to the device going offline, the cached version will be
returned (if available).
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
DriveContents
when they are available. IfisSuccess()
returns true, it is recommended to checkgetStatusCode()
, since two possible values are considered success:SUCCESS
which means that the returnedDriveContents
is up to date, orSUCCESS_CACHE
which means that the returnedDriveContents
is a cached version, since the most up to date version could not be downloaded to the device (for example, due to connectivity).