Reputation: 1068
Is it possible to to sync selected files in a folder/directory from Android device to Google Drive with Drive & Android API.What Kind of things do i need to study or look in to, in order to do it.
Google Drive to Android device sync
Android device to Google Drive sync
Upvotes: 1
Views: 886
Reputation: 6755
First, the easy and obvious:
There are 2 Apis, the REST Api (v2, v3) and the GDAA. Both will give you at least CRUD functionality (see here and here). If you go with the REST
Api, you get more low level functionality, BUT you have to handle the network issues (sync service?). GDAA
will take care of that (on/off-line state, etc).
Now, the not so easy part, how to synchronize:
The REST Api has a build-in functionality, Push Notifications, so it looks like a winner. Until you realize that you have to supply a server that handles the notification and sends it (through GCM?) to your Android app. If you add the need for handling network states, the REST Api Push Notifications certainly needs a lot of guts to implement.
From my 'playing around', the most elegant way so far was using GDAA in combination with Firebase. GDAA
handles the CRUD, Firebase
communicates.
Here is a raw algo:
for android device under GDAA
1/ Android app creates a file, receives completion notification with ResourceId
2/ adds ResourceId to Firebase
3/ every Firebase participant gets notification
or for Android app under REST or other entities (web, ios)
1/ an app (REST, web, ios) creates a file yielding ResourceId
2/ adds file's ResourceId to Firebase
3/ every Firebase participant gets notification
GDAA works for me since both 'updaters' are the same Android app (basically synchronizing the same app's data between devices). Unfortunately, since GDAA does not support the DRIVE scope, it will not see files created by 'other entities', so you may still consider a 'REST+Firebase' solution.
A word of caution:
Be careful about the bandwidth / battery consumption. Anytime you touch the Firebase update methods, there will be instant network traffic causing battery drain, defeating the work GDAA is doing to minimize it.
Good Luck
Upvotes: 1