DriveClient

public abstract class DriveClient extends GoogleApi<Drive.ConnectionlessDriveOptions>

Client for basic interactions with the Drive API.

Public Method Summary

abstract Task<DriveId>
getDriveId(String resourceId)
Returns the DriveId associated with the provided resourceId.
abstract Task<TransferPreferences>
getUploadPreferences()
Returns the TransferPreferences for file uploads performed by the calling application.
abstract Task<IntentSender>
newCreateFileActivityIntentSender(CreateFileActivityOptions options)
Creates an IntentSender that can be used to start a dialog activity with the specified options that allows the user to create a new file in his/her Drive.
abstract Task<IntentSender>
newOpenFileActivityIntentSender(OpenFileActivityOptions options)
Creates an IntentSender that can be used to start a dialog activity with the specified options that allows the user to open an existing file.
abstract Task<Void>
requestSync()
Requests synchronization with the server to download any metadata changes that have occurred since the last sync with the server.
abstract Task<Void>
setUploadPreferences(TransferPreferences transferPreferences)
Sets the TransferPreferences for file uploads performed by the calling application to the specified transferPreferences and returns the status of the operation.

Inherited Method Summary

Public Methods

public abstract Task<DriveId> getDriveId (String resourceId)

Returns the DriveId associated with the provided resourceId. This Drive ID can be used to retrieve the Drive file or folder, via asDriveFile() or asDriveFolder().

public abstract Task<TransferPreferences> getUploadPreferences ()

Returns the TransferPreferences for file uploads performed by the calling application. These preferences dictate how files that are created or edited by the application are uploaded to the server from the device.

public abstract Task<IntentSender> newCreateFileActivityIntentSender (CreateFileActivityOptions options)

Creates an IntentSender that can be used to start a dialog activity with the specified options that allows the user to create a new file in his/her Drive.

Once the user has chosen to create the new file, its DriveId can be retrieved via the extra EXTRA_RESPONSE_DRIVE_ID.

Note: You must use #startIntentSenderForResult to invoke the activity.

This method requires authorization with SCOPE_FILE.

public abstract Task<IntentSender> newOpenFileActivityIntentSender (OpenFileActivityOptions options)

Creates an IntentSender that can be used to start a dialog activity with the specified options that allows the user to open an existing file.

Once the user has selected a file, the DriveId of that file can be retrieved via the extra EXTRA_RESPONSE_DRIVE_ID. The file is also automatically authorized for access by the calling application.

Note: You must use #startIntentSenderForResult to invoke the activity.

This method requires authorization with SCOPE_FILE.

public abstract Task<Void> requestSync ()

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

Typically, this method should be called when the user requests a refresh of their list of files. Once this method returns, performing a query will return fresh results.

In order to avoid excessive load on the device and server, sync requests are rate-limited. If the request has been rate-limited, the operation will fail with the DRIVE_RATE_LIMIT_EXCEEDED status. This indicates that a sync has already occurred recently so there is no need for another. After a sufficient backoff duration, the operation will succeed when re-attempted.

public abstract Task<Void> setUploadPreferences (TransferPreferences transferPreferences)

Sets the TransferPreferences for file uploads performed by the calling application to the specified transferPreferences and returns the status of the operation. These preferences dictate how files that are created or edited by the application are uploaded to the server from the device.

If the application regularly uploads large files to the user's Drive, it is advisable to use these preferences to control when the files should be uploaded, based on network connectivity, battery usage, etc.

Note: Preferences will be applied to both future and pending file uploads performed by the application. For example, if the application sets the preferences to upload files only on WiFi then tries to upload a file while the device is on mobile data, the file will not be uploaded; however, if the application later changes the preferences to upload files on WiFi or mobile data, then the file will be scheduled for upload at that time.