Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trash, Delete in new Google Drive Android API?

UPDATE (May 2015):
the 'trash' functionality has been implemented in GDAA, making the question below irrelevant.

ORIGINAL QUESTION:
As I play with the new "Google Drive Android API" (GDAA), I am running into a few discrepancies I can't figure out. Basically, I have an old app that uses the "com.google.api.services.drive" interface (insert, patch, update) and I WOULD LOVE to port it to GDAA.

First, GDAA vs. drive.google.com web app.
With the old service, I used the DriveScopes.DRIVE_FILE scope, so I assumed similar behavior/results. Files created with the old "DriveScopes.DRIVE_FILE" can be deleted by me (the Drive owner) in "https://drive.google.com" (I assume that my scope is DRIVE there) and subsequent Android app queries will not find them. It behaves as I would expect:

  1. The Android app creates files.
  2. User deletes them on "drive.google.com".
  3. Android app does not see them anymore.

With the new GDAA, it does not seem to work. Which brings me to the second point:

DELETE/TRASH functionality.
I was trying to test CRUD functionality and couldn't find DELETE at all (again, it may be my ignorance/shortsightedness). Deleting them from "drive.google.com" makes them invisible there, but the Android app still sees them. Metadata can inquire through "isTrashed()", but there is nothing in "MetadataChangeSet.Builder" that would let me delete/trash them, only setMimeType(), setStarred(), setTitle().

I'm lost, please help.

like image 997
seanpj Avatar asked Jan 26 '14 21:01

seanpj


People also ask

How do I delete files from Google Drive API?

def delete_file(service, file_id): """Permanently delete a file, skipping the trash. Args: service: Drive API service instance.


2 Answers

If you want to have a full control over synchronization, do not use Google Drive Android NEW API (at least for now). It is not good enough yet (October 2014) or respectively it works in different way than "real time" OLD API. Main problems are, that you can't delete file, changes are not real-time, metadata are often cached a lot (when I make a search query, in results I can see deleted files even after many hours!). Probably due to some optimizations drive services runs when they want and how they want, so almost nothing is under your control - you never know how drive service uses cache, and you can't force drive service to "do the job right now because I need it".

Oh, and another disadvantage is, that code is much more complicated that same logic created in OLD API :)

like image 92
qkx Avatar answered Sep 29 '22 11:09

qkx


Google Drive Android API doesn't sync with the remote resources instantly. Depending on the scheduler, it may take a while to sync. The scheduling is dependant to Android's account sync components those are making sure that network bandwidth and battery life is conserved and efficiently used.

Additionally, as of Developer Preview, we don't support deletion or trashing. But, the next release will likely to support these actions.

like image 28
Burcu Dogan Avatar answered Sep 29 '22 09:09

Burcu Dogan