DriveResourceClient Stay organized with collections Save and categorize content based on your preferences.
Page Summary
The
DriveResourceClientis a deprecated class from the Google Drive Android API, which was turned down on December 6, 2019.This class provided a contract for interacting with
DriveResourceobjects like files and folders.All public methods of
DriveResourceClientare deprecated, and developers should migrate to the REST API.Several deprecated methods for interacting with Drive resources are detailed, including operations for managing files, folders, and their metadata.
This class is deprecated.
The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API.
The contract for anyDriveResource (i.e.DriveFile orDriveFolder).
Inherited Field Summary
| protected final GoogleApiManager | zabm |
Public Method Summary
| abstractTask<ListenerToken> | addChangeListener(DriveResource resource,OnChangeListener listener) This method is deprecated. The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API. |
| abstractTask<Void> | addChangeSubscription(DriveResource resource) This method is deprecated. The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API. |
| abstractTask<Boolean> | cancelOpenFileCallback(ListenerToken token) This method is deprecated. The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API. |
| abstractTask<Void> | commitContents(DriveContents contents,MetadataChangeSet changeSet) This method is deprecated. The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API. |
| abstractTask<Void> | commitContents(DriveContents contents,MetadataChangeSet changeSet,ExecutionOptions executionOptions) This method is deprecated. The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API. |
| abstractTask<DriveContents> | createContents() This method is deprecated. The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API. |
| abstractTask<DriveFile> | createFile(DriveFolder folder,MetadataChangeSet changeSet,DriveContents driveContents,ExecutionOptions executionOptions) This method is deprecated. The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API. |
| abstractTask<DriveFile> | createFile(DriveFolder folder,MetadataChangeSet changeSet,DriveContents driveContents) This method is deprecated. The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API. |
| abstractTask<DriveFolder> | createFolder(DriveFolder folder,MetadataChangeSet changeSet) This method is deprecated. The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API. |
| abstractTask<Void> | delete(DriveResource resource) This method is deprecated. The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API. |
| abstractTask<Void> | discardContents(DriveContents contents) This method is deprecated. The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API. |
| abstractTask<DriveFolder> | getAppFolder() This method is deprecated. The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API. |
| abstractTask<Metadata> | getMetadata(DriveResource resource) This method is deprecated. The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API. |
| abstractTask<DriveFolder> | getRootFolder() This method is deprecated. The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API. |
| abstractTask<MetadataBuffer> | listChildren(DriveFolder folder) This method is deprecated. The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API. |
| abstractTask<MetadataBuffer> | listParents(DriveResource resource) This method is deprecated. The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API. |
| abstractTask<DriveContents> | openFile(DriveFile file, int openMode) This method is deprecated. The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API. |
| abstractTask<ListenerToken> | openFile(DriveFile file, int openMode,OpenFileCallback callback) This method is deprecated. The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API. |
| abstractTask<MetadataBuffer> | query(Query query) This method is deprecated. The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API. |
| abstractTask<MetadataBuffer> | queryChildren(DriveFolder folder,Query query) This method is deprecated. The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API. |
| abstractTask<Boolean> | removeChangeListener(ListenerToken token) This method is deprecated. The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API. |
| abstractTask<Void> | removeChangeSubscription(DriveResource resource) This method is deprecated. The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API. |
| abstractTask<DriveContents> | reopenContentsForWrite(DriveContents contents) This method is deprecated. The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API. |
| abstractTask<Void> | setParents(DriveResource resource,Set<DriveId> parentIds) This method is deprecated. The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API. |
| abstractTask<Void> | trash(DriveResource resource) This method is deprecated. The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API. |
| abstractTask<Void> | untrash(DriveResource resource) This method is deprecated. The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API. |
| abstractTask<Metadata> | updateMetadata(DriveResource resource,MetadataChangeSet changeSet) This method is deprecated. The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API. |
Inherited Method Summary
| GoogleApiClient | asGoogleApiClient() |
| ClientSettings.Builder | createClientSettingsBuilder() |
| Task<Boolean> | disconnectService() |
| <A extends Api.AnyClient, T extends ApiMethodImpl<? extends Result, A>> T | doBestEffortWrite(ApiMethodImpl arg0) |
| <TResult, A extends Api.AnyClient>Task<TResult> | doBestEffortWrite(TaskApiCall<A, TResult> arg0) |
| <A extends Api.AnyClient, T extends ApiMethodImpl<? extends Result, A>> T | doRead(ApiMethodImpl arg0) |
| <TResult, A extends Api.AnyClient>Task<TResult> | doRead(TaskApiCall<A, TResult> arg0) |
| <A extends Api.AnyClient>Task<Void> | doRegisterEventListener(RegistrationMethods arg0) |
| <A extends Api.AnyClient, T extends RegisterListenerMethod<A, ?>, U extends UnregisterListenerMethod<A, ?>>Task<Void> | doRegisterEventListener(RegisterListenerMethod arg0, UnregisterListenerMethod arg1) |
| Task<Boolean> | doUnregisterEventListener(ListenerKey arg0) |
| <TResult, A extends Api.AnyClient>Task<TResult> | doWrite(TaskApiCall<A, TResult> arg0) |
| <A extends Api.AnyClient, T extends ApiMethodImpl<? extends Result, A>> T | doWrite(ApiMethodImpl arg0) |
| finalApi<Drive.ConnectionlessDriveOptions> | getApi() |
| Drive.ConnectionlessDriveOptions | getApiOptions() |
| Context | getApplicationContext() |
| final int | getInstanceId() |
| Looper | getLooper() |
| <L> ListenerHolder<L> | |
| zace | |
| Api.Client | |
| final zai<Drive.ConnectionlessDriveOptions> | zak() |
Public Methods
public abstractTask<ListenerToken>addChangeListener(DriveResource resource,OnChangeListener listener)
This method is deprecated.
The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API.
Adds the specifiedlistener to be notified of changes to the specifiedresource.
The listener will remain active for the duration of the process or until removeChangeListener(ListenerToken) is called with the sameListenerToken returned by this method.
public abstractTask<Void>addChangeSubscription(DriveResource resource)
This method is deprecated.
The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API.
Adds a subscription for thisresource that will deliver events to the application'sDriveEventService subclass when changes to this resource are visible to the client.
The application'sDriveEventService subclass should implement onChange(ChangeEvent) in order to handle the incomingChangeEvent objects.
The subscription is persistent and will remain active until the next device reboot or until removeChangeSubscription(DriveResource) is called. The client is responsible for registering the subscription again after a device reboot if it is still desired.
public abstractTask<Boolean>cancelOpenFileCallback(ListenerToken token)
This method is deprecated.
The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API.
Cancels callback passed into openFile(DriveFile, int, OpenFileCallback) with theListenerToken returned from theopen() call.
Note: The Callback is cancelled for you after onContents(DriveContents) or onError(Exception) is called.
Returns
trueif callback was cancelled,falseif callback was already cancelled or not registered in the first place.
public abstractTask<Void>commitContents(DriveContents contents,MetadataChangeSet changeSet)
This method is deprecated.
The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API.
Commits thecontents and updates its metadata tochangeSet (if provided). This method should only be used onDriveContents that are already associated to a particularDriveFile, obtained through openFile(DriveFile, int).
This method will commit contents using the default CONFLICT_STRATEGY_OVERWRITE_REMOTE strategy, will not notify for aCompletionEvent, and will have no tracking tags. If you'd like to specify different options, use commitContents(DriveContents, MetadataChangeSet, ExecutionOptions) instead.
After this method returns,contents will be closed and no longer usable.
Throws
| IllegalStateException | if one of the following is true:
|
|---|
public abstractTask<Void>commitContents(DriveContents contents,MetadataChangeSet changeSet,ExecutionOptions executionOptions)
This method is deprecated.
The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API.
Commits thecontents and updates its metadata tochangeSet (if provided). Extra settings for this action, such as a conflict resolution strategy or completion notification request, can be specified inexecutionOptions. SeeExecutionOptions for a complete list of options. This method should only be used onDriveContents that are already associated to a particularDriveFile, obtained through openFile(DriveFile, int).
A file conflict happens when the written contents are not applied on top of the file revision that Drive originally provided when the contents were read by the application. A conflict could happen when an application reads contents at revision X, then writes revision X+1 and, by the time X+1 is committed or updated on the server, the file version is not X anymore (because, e.g. another app or a remote change already modified the file to revision X').
After this method returns,contents will be closed and no longer usable.
Throws
| IllegalStateException | if one of the following is true:
|
|---|
public abstractTask<DriveContents>createContents()
This method is deprecated.
The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API.
Creates a newDriveContents instance that can be used to provide initial contents for a newDriveFile. The returned contents will be inMODE_WRITE_ONLY and can be used to write the initial contents.
To be persisted, the contents must be saved by being passed as an argument to createFile(DriveFolder, MetadataChangeSet, DriveContents), {@link #createFile(DriveFolder, MetadataChangeSet, DriveContents, ExecutionOptions) or {@link CreateFileActivityOptions.Builder#setInitialDriveContents(DriveContents)}.
public abstractTask<DriveFile>createFile(DriveFolder folder,MetadataChangeSet changeSet,DriveContents driveContents,ExecutionOptions executionOptions)
This method is deprecated.
The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API.
Creates a new binaryDriveFile withinfolder, with the initial metadata provided inchangeSet, initial contents provided indriveContents, and method execution options provided inexecutionOptions. In order to create the file with empty contents, pass innull fordriveContents. It is recommended that files with a mime-type that does not support having a zero-byte file (e.g. an image or PDF) is created as a non-empty file.
Note: setConflictStrategy(int) is not supported for this method.
You must obtaindriveContents via createContents(). Once this method returns,driveContents will be persisted and closed. In order to continue editing the file's contents, they must be opened again with openFile(DriveFile, int) or openFile(DriveFile, int, OpenFileCallback).
If you want to use the defaultExecutionOptions, call createFile(DriveFolder, MetadataChangeSet, DriveContents) instead.
public abstractTask<DriveFile>createFile(DriveFolder folder,MetadataChangeSet changeSet,DriveContents driveContents)
This method is deprecated.
The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API.
Creates a new binaryDriveFile withinfolder, with the initial metadata provided inchangeSet and initial contents provided indriveContents. In order to create the file with empty contents, pass innull. It is recommended that files with a mime-type that does not support having a zero-byte file (e.g. an image or PDF) is created as a non-empty file.
You must obtaindriveContents via createContents(). Once this method returns,driveContents will be persisted and closed. In order to continue editing the file's contents, they must be opened again with openFile(DriveFile, int) or openFile(DriveFile, int, OpenFileCallback).
This method behaves like createFile(DriveFolder, MetadataChangeSet, DriveContents, ExecutionOptions) with {@code null {@link ExecutionOptions}, which means completion event notifications will not be sent and there is no operation tag.
public abstractTask<DriveFolder>createFolder(DriveFolder folder,MetadataChangeSet changeSet)
This method is deprecated.
The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API.
Creates a newDriveFolder withinfolder, with the initial metadata provided inchangeSet.
Note: At minimum, setTitle(String) must be called.
setMimeType(String) does not need to be called, as the mime-type will automatically be set toMIME_TYPE.
public abstractTask<Void>delete(DriveResource resource)
This method is deprecated.
The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API.
Permanently deletes thisresource, bypassing trash. The user must be the owner. Ifresource is aDriveFolder, the app must have access to all of its descendants.
For user-visible resources, we recommend using trash(DriveResource) 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() for more information.
public abstractTask<Void>discardContents(DriveContents contents)
This method is deprecated.
The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API.
Discardscontents and any changes that were performed on it. Calling this method will not save any changes performed on this object.
After this method returns,contents will be closed and no longer usable.
public abstractTask<DriveFolder>getAppFolder()
This method is deprecated.
The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API.
Returns the app folder.
The app folder is a special folder within Drive that is only accessible by your application. Its contents are hidden from the user and from other apps. Although it is hidden from the user, the app folder does count against the user's Drive storage quota.
The app folder can be used to store configuration files, temporary files, etc. that belong to the user but should not be tampered with.
SCOPE_APPFOLDER is required to access this folder; otherwise, it fails with the error status DEVELOPER_ERROR.
See theStoring Application Data guide for more information.
public abstractTask<Metadata>getMetadata(DriveResource resource)
This method is deprecated.
The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API.
Retrieves theMetadata associated with thisresource.
public abstractTask<DriveFolder>getRootFolder()
This method is deprecated.
The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API.
Returns the root folder.
SCOPE_FILE is required to access this folder; otherwise, it fails with the error status DEVELOPER_ERROR.
public abstractTask<MetadataBuffer>listChildren(DriveFolder folder)
This method is deprecated.
The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API.
Retrieves a collection of metadata for the direct children, including both files and folders, offolder.
Be sure to callrelease() when finished with the result.
public abstractTask<MetadataBuffer>listParents(DriveResource resource)
This method is deprecated.
The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API.
Retrieves the collection of metadata for all of the parents of thisresource that the calling app has been authorized to view.
Be sure to callrelease() when finished with the result.
public abstractTask<DriveContents>openFile(DriveFile file, int openMode)
This method is deprecated.
The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API.
Opens theDriveContents that are associated with thisfile in the requestedopenMode. The returned contents is a temporary copy available only to this app. The contents must be closed via commitContents(DriveContents, MetadataChangeSet) or discardContents(DriveContents).
Note: To open the file in edit mode, the user must have edit access. SeeisEditable() for more information.
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.
Note: If the download fails (e.g. due to the device going offline) the cached version will be returned if available.
public abstractTask<ListenerToken>openFile(DriveFile file, int openMode,OpenFileCallback callback)
This method is deprecated.
The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API.
Opens theDriveContents that are associated with thisfile in the requestedopenMode. The providedOpenFileCallback will receive a temporary copy of the contents available only to this app. The contents must be closed via commitContents(DriveContents, MetadataChangeSet) or discardContents(DriveContents). The returnedListenerToken can be used to cancel the download.
Note: To open the file in edit mode, the user must have edit access. SeeisEditable() for more information.
Note: If the download fails (e.g. due to the device going offline) the cached version will be returned if available.
public abstractTask<MetadataBuffer>query(Query query)
This method is deprecated.
The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API.
Retrieves a collection of metadata for the files and folders that match the restrictions specified inquery.
Be sure to callrelease() when finished with the result.
public abstractTask<MetadataBuffer>queryChildren(DriveFolder folder,Query query)
This method is deprecated.
The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API.
Retrieves a collection of metadata for the files and folders that match the restrictions specified inquery and are direct children offolder.
Be sure to callrelease() when finished with the result.
public abstractTask<Boolean>removeChangeListener(ListenerToken token)
This method is deprecated.
The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API.
Removes theOnChangeListener associated with thistoken from listening to changes to the associatedDriveResource. Thetoken must be the sameListenerToken that was returned by addChangeListener(DriveResource, OnChangeListener).
Returnstrue if removing the listener was successful.
public abstractTask<Void>removeChangeSubscription(DriveResource resource)
This method is deprecated.
The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API.
Removes the existing Change subscription for thisresource.
public abstractTask<DriveContents>reopenContentsForWrite(DriveContents contents)
This method is deprecated.
The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API.
Closes thecontents and returns a newDriveContents opened inMODE_WRITE_ONLY. The returned contents are usable for conflict detection.
After this method returns,contents will be closed and will no longer be usable
This method is often used in conjunction with commitContents(DriveContents, MetadataChangeSet).
Throws
| IllegalStateException | if this method is called on contents that are currently opened in MODE_WRITE_ONLY orMODE_READ_WRITE or on contents that have been closed |
|---|
public abstractTask<Void>setParents(DriveResource resource,Set<DriveId> parentIds)
This method is deprecated.
The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API.
Sets the parents ofresource to theDriveId instances defined inparentIds. This will overwrite the current parent IDs withparentIds, so any parent IDs that should remain as parents but also be supplied in the Set. Do NOT modifyparentIds after calling this method.
All parent IDs must be associated withDriveFolder resources.
If thisresource is in the App Folder or one of its subfolders, all parents must also belong to the App Folder or one of its subfolders. Similarly, if thisresource is outside of the App Folder, every parent must also be outside of the App Folder.
public abstractTask<Void>trash(DriveResource resource)
This method is deprecated.
The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API.
Moves theresource to trash. The user must be the owner. If the resource is aDriveFolder, the app must have access to all of its descendants.
Resources inside the App Folder cannot be trashed. See getAppFolder() for more information.
public abstractTask<Void>untrash(DriveResource resource)
This method is deprecated.
The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API.
Moves theresource out of the trash. The user must be the owner. If the resource is aDriveFolder, the app must have access to all of its descendants.
Resources inside the App Folder cannot be untrashed (because they cannot be trashed). See getAppFolder() for more information.
public abstractTask<Metadata>updateMetadata(DriveResource resource,MetadataChangeSet changeSet)
This method is deprecated.
The Google Drive Android API is deprecated and will be turned down on December 6, 2019. See themigration guide for instructions on migrating to the REST API.
Updates theMetadata that is associated with thisresource with the changes defined inchangeSet.
Note that the user must have edit access to update certain metadata fields. SeeMetadataChangeSet.Builder for more information.
Note that the metadata of the root folder cannot be updated.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-31 UTC.