0

I am implementing an application which can sync a document which is in google drive. As the first step, I could make initial contacts with the Drive and I could take the file id for selected file and other metadata.

But as the next step, I need to sync with the file on the google drive. When the user is updating the local document I need to sync the updated texts and other stuff with Google Drive.

Is this possible or not?. If it is possible, What is the code?

1 Answers1

0

When you open a file in drive Android API local syncing happens.

The DriveFile.open method retrieves the locally synced file resource and opens it. If the file is not synced with the local storage, it retrieves the file from the Drive service and returns a DriveContents resource. For example:

 DriveFile file = ... file.open(mGoogleApiClient,
 DriveFile.MODE_READ_ONLY, null)
         .setResultCallback(contentsOpenedCallback);

A DriveContents resource contains a temporary copy of the file's binary stream which is only available to your application. If multiple applications are accessing the same file, there are no race conditions between DriveContents resources. In this situation, the last write operation will be the final state of the content.

Handling the response requires you to check if the call was successful or not. If the call was successful, you can retrieve the DriveContents resource. This resource contains methods to retrieve an InputStream or ParcelFileDescriptor to read the file's binary contents

ReyAnthonyRenacia
  • 17,219
  • 5
  • 37
  • 56