com.google.android.gms.drive.DriveApi |
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.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
DriveApi.DriveContentsResult | Result that contains a DriveContents . |
||||||||||
DriveApi.DriveIdResult | Result that contains a DriveId . |
||||||||||
DriveApi.MetadataBufferResult | Result that contains a MetadataBuffer . |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
This method is deprecated.
This API is being discontinued.
| |||||||||||
Retrieves a
DriveId object that can be used in further drive api operations (e.g. | |||||||||||
Returns a
DriveFolder object that can be used to interact with the App Folder. | |||||||||||
This method is deprecated.
Use
asDriveFile() instead
| |||||||||||
This method is deprecated.
Use
asDriveFolder() instead
| |||||||||||
Returns a
DriveFolder object that can be used to interact with the root folder. | |||||||||||
This method is deprecated.
With no replacement
| |||||||||||
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.
| |||||||||||
Retrieves a new
DriveContents instance that can be used to provide initial contents
for a new file. | |||||||||||
Creates a builder for an Open File activity that allows user selection of a Drive file.
| |||||||||||
Retrieves a collection of metadata for the files and folders that match the specified query.
| |||||||||||
Requests synchronization with the server to download any metadata changes that occurred since
the last sync with the server.
|
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 | |
---|---|
apiClient |
GoogleApiClient
|
trackingTags |
List :
the list of tracking tags that identify the actions that should be
canceled. |
Returns | |
---|---|
PendingResult<Status> |
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. |
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 |
GoogleApiClient :
The GoogleApiClient to service the call. |
resourceId |
String :
The Drive resource id for the DriveId to retrieve. |
Returns | |
---|---|
PendingResult<DriveApi.DriveIdResult> |
A PendingResult which can be used to retrieve the DriveId object. |
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 |
GoogleApiClient :
The GoogleApiClient to service the call. The client must be
connected using connect() before invoking this method. |
Returns | |
---|---|
DriveFolder |
Throws | |
---|---|
IllegalStateException |
if this method is called before the client is connected. |
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 |
GoogleApiClient :
The GoogleApiClient to service the call. The client must be
connected using connect() before invoking this method. |
id |
DriveId
|
Returns | |
---|---|
DriveFile |
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 |
GoogleApiClient :
The GoogleApiClient to service the call. The client must be
connected using connect() before invoking this method. |
id |
DriveId
|
Returns | |
---|---|
DriveFolder |
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 |
GoogleApiClient :
The GoogleApiClient to service the call. The client must be
connected using connect() before invoking this method. |
Returns | |
---|---|
DriveFolder |
Throws | |
---|---|
IllegalStateException |
if this method is called before the client is connected. |
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 |
GoogleApiClient :
The GoogleApiClient to service the call. The client must be
connected before invoking this method. |
Returns | |
---|---|
PendingResult<BooleanResult> |
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.
Returns | |
---|---|
CreateFileActivityBuilder |
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 |
GoogleApiClient :
The GoogleApiClient to service the call. The client must be
connected using connect() before invoking this method. |
Returns | |
---|---|
PendingResult<DriveApi.DriveContentsResult> |
A PendingResult which can be used to retrieve the Contents object. |
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.
Returns | |
---|---|
OpenFileActivityBuilder |
Retrieves a collection of metadata for the files and folders that match the specified query.
Parameters | |
---|---|
apiClient |
GoogleApiClient :
The GoogleApiClient to service the call. |
query |
Query :
The query that will restrict the contents of the result set. |
Returns | |
---|---|
PendingResult<DriveApi.MetadataBufferResult> |
A PendingResult which can be used to retrieve the result set. Be sure to call
release() when you're done with the result.
|
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 |
GoogleApiClient :
The GoogleApiClient to service the call. The client must be
connected before invoking this method. |
Returns | |
---|---|
PendingResult<Status> |
a PendingResult that returns when synchronization has completed.
|