1

If you want to sync some custom data between your Android app and remote server, usually you need to implement a local storage for the data, Content Provider, and Sync Adapter to perform custom syncing.

What if in my app I am using standard Calendar Provider with its storage and want to sync my changes with Google Calendar server - how can I use the standard built in way to sync instead of reinventing the wheel and implement what Android can do by itself - all specific pulls/pushes/updates etc? By the built in way I mean what Android does on any device when you go to Settings > Accounts > Google and simply click Sync Calendar.

In my understanding, all I need to do is to execute this built in functionality in onPerformSync() of my Sync Adapter, so how can I do that?

Zmiter
  • 298
  • 4
  • 15
  • If you are "using standard Calendar Provider with its storage", what do you have to sync? The Calendar app is responsible for doing its own syncing with Google's servers. – CommonsWare Apr 16 '16 at 17:48
  • 1
    My app creates its own "events" in Calendar Provider tables. If the Calendar app is installed, it syncs my events by itself. But if the Calendar app is not installed, I can only sync manually from Settings > Accounts > Google – Zmiter Apr 16 '16 at 17:53
  • If the Calendar app is not installed, then I would not be using the calendar provider. Regardless, the code that lies behinds Settings > Accounts > Google would be proprietary to Google. – CommonsWare Apr 16 '16 at 17:58
  • Can you please explain why you would not be using the Calendar Provider? I thought this provider is public and used by multiple third-party calendar apps. – Zmiter Apr 16 '16 at 18:06
  • 1
    It is public. It is used by multiple third-party calendar apps. However, if the Calendar app is not installed, I have limited trust in where that calendar data would wind up going. For example, I am not aware of any device that legitimately has Settings > Accounts > Google that does not have the Calendar app. After all, the Google sync code is part of the same bundle that device manufacturers license along with Calendar, and AFAIK they have to ship all of it, not just pieces. – CommonsWare Apr 16 '16 at 18:11
  • 1
    Thanks. Regarding the devices - Samsung Galaxy Note devices don't have the Calendar app preinstalled (though they have their own S Planner preinstalled, but I don't think it matters). – Zmiter Apr 16 '16 at 18:17
  • Fascinating! I just pulled out a Note 3 and confirmed your findings. I thought all the proprietary apps were needed, but apparently it's just a subset (mostly those in the Google group on the stock launcher). My sincere apologies. – CommonsWare Apr 16 '16 at 18:21
  • Still can't understand this: Google provides Calendar Provider, provides Google Calendar API, but at same time does not allow to use what lies behind Settings > Accounts > Google > Sync Calendar. I don't event need the source code, but a public method... Does not make any sense to me. – Zmiter Apr 18 '16 at 11:50

0 Answers0