thanhbinh84
thanhbinh84

Reputation: 18454

The Google Drive Android SDK sync local folder strategy

I read throughly development documents, sample code and SO related Q&A, it seems the Google Drive Android SDK doesn't include any functionality to automatically sync local folders. Therefore I am going to build one by my own, and here is the strategy:

During searching, I found the Transfer data using sync adapters lesson but I am not sure if it is useful for this case.

Upvotes: 1

Views: 685

Answers (1)

pinoyyid
pinoyyid

Reputation: 22296

A couple of pointers

  1. You need to differentiate between a content/media sync vs a metadata sync. Eg. if I rename a file, I only want to sync the new filename, not the file content. Therefore you need two status flags. If you use the V2 API, you can use ETAGs, but they have disappeared in v3. So you might want to use MD5 checksum to detect changes.
  2. You´ll need to deal with sub-folders, either with recursion or by using a universal parent folder.
  3. Guard against sync-loops when you update a local file, sync to a GDrive file, which then shows up as a change on GDrive and triggers a download.
  4. SyncAdapters are your friend, even though they seem hostile at first.

Upvotes: 2

Related Questions