SlideShare una empresa de Scribd logo
1 de 83
Descargar para leer sin conexión
Sync              ON ANDROID


Jerzy Chalupski
chalup
jerzy@futuresimple.com
What we do in general...
What we do ALL THE TIME




                          sync, sync, sync, sync
Sync     ON ANDROID




   OVERVIEW                ARCHITECTURE

CONTENT PROVIDER         PITFALLS & PROTIPS
Sync     ON ANDROID




   OVERVIEW                ARCHITECTURE

CONTENT PROVIDER         PITFALLS & PROTIPS
Not exactly the fresh topic...




        „Developing Android REST client
        applications”
                                     by Virgil Dobjanschi
                                       @Google I/O 2010
Not exactly the fresh topic...




        „Synchronizacja danych z serwisami
        webowymi w Androidzie”
                                   by Bartosz Filipowicz
                                       @KrakDroid 2011
Not exactly the fresh topic...




        „Synchronizacja danych z serwisami
        webowymi w Androidzie”
                                       by Bartosz Filipowicz
                                           @KrakDroid 2011




                        ...but there is still much confusion
AccountManager
 SyncManager
                  UI     Authenticator

ContentProvider
                          SyncAdapter
    ContentResolver
„Wat? Why do I need to write
all this crap, sync is just
fetching data from server”
                         typical reaction
Sync provides data sharing
Sync provides data sharing
             offline mode
Sync provides data sharing
             offline mode
             responsive UI
Sync provides data sharing
             offline mode
             responsive UI

              GREAT UX
Sync     ON ANDROID




   OVERVIEW                ARCHITECTURE

CONTENT PROVIDER         PITFALLS & PROTIPS
ContentProvider 101: CRUD



       CREATE               insert()


       READ                 query()


       UPDATE               update()


       DELETE               delete()
ContentProvider 101: URI




       content://com.futuresimple.krakdroid.Provider/datasets/1
ContentProvider 101: URI




       content://com.futuresimple.krakdroid.Provider/datasets/1
ContentProvider 101: URI




       content://com.futuresimple.krakdroid.Provider/datasets/1
ContentProvider 101: URI




       content://com.futuresimple.krakdroid.Provider/datasets/1
ContentProvider 101: notifications




       content://com.futuresimple.krakdroid.Provider/datasets/1
       content://com.futuresimple.krakdroid.Provider/solutions
       content://com.futuresimple.krakdroid.Provider/solutions/1
       content://com.futuresimple.krakdroid.Provider/solutions/1/answers/1
       content://com.futuresimple.krakdroid.Provider/solutions/1/answers/2
       content://com.futuresimple.krakdroid.Provider/solutions/2/answers/1
ContentProvider 101: notifications




       content://com.futuresimple.krakdroid.Provider/datasets/1
       content://com.futuresimple.krakdroid.Provider/solutions
       content://com.futuresimple.krakdroid.Provider/solutions/1
       content://com.futuresimple.krakdroid.Provider/solutions/1/answers/1
       content://com.futuresimple.krakdroid.Provider/solutions/1/answers/2
       content://com.futuresimple.krakdroid.Provider/solutions/2/answers/1


           ContentResolver.notifyChange(“content://
       com.futuresimple.krakdroid.Provider/datasets/1”);
ContentProvider 101: notifications




        content://com.futuresimple.krakdroid.Provider/datasets/1
        content://com.futuresimple.krakdroid.Provider/solutions
        content://com.futuresimple.krakdroid.Provider/solutions/1
        content://com.futuresimple.krakdroid.Provider/solutions/1/answers/1
        content://com.futuresimple.krakdroid.Provider/solutions/1/answers/2
        content://com.futuresimple.krakdroid.Provider/solutions/2/answers/1


             ContentResolver.notifyChange(“content://
   com.futuresimple.krakdroid.Provider/solutions/1/answers/1”);
Sync     ON ANDROID




   OVERVIEW                ARCHITECTURE

CONTENT PROVIDER         PITFALLS & PROTIPS
AccountManager
 SyncManager
                  UI     Authenticator

ContentProvider
                          SyncAdapter
    ContentResolver
Authenticator                   Sync architecture
                                    CREATING NEW ACCOUNT




AccountManager
        addAccount()


                       UI

 SyncManager                ContentResolver



 SyncAdapter                ContentProvider
Authenticator                   Sync architecture
                                    CREATING NEW ACCOUNT
        addAccount()




AccountManager
        addAccount()


                       UI

 SyncManager                ContentResolver



 SyncAdapter                ContentProvider
Authenticator                   Sync architecture
                                    CREATING NEW ACCOUNT
        addAccount()




AccountManager
        addAccount()


                       UI

 SyncManager                ContentResolver



 SyncAdapter                ContentProvider
Authenticator             Sync architecture
                                    SHOW SYNCED DATA




AccountManager

                 UI
                              query()




 SyncManager          ContentResolver

                              query()




 SyncAdapter          ContentProvider
Authenticator                          Sync architecture
                                                 REQUEST SYNC




AccountManager
        getAccountsByType()


                              UI

 SyncManager                       ContentResolver



 SyncAdapter                       ContentProvider
Authenticator                          Sync architecture
                                                       REQUEST SYNC




AccountManager
        getAccountsByType()


                              UI           requestSync()




 SyncManager                       ContentResolver



 SyncAdapter                       ContentProvider
Authenticator                                  Sync architecture
                                                                 REQUEST SYNC




AccountManager
                  getAccountsByType()


                                        UI           requestSync()




   SyncManager                               ContentResolver

onPerformSync()




   SyncAdapter                               ContentProvider
Authenticator             Sync architecture
                                             EDIT DATA




AccountManager

                 UI               insert()




 SyncManager          ContentResolver

                                  insert()




 SyncAdapter          ContentProvider
Authenticator                         Sync architecture
                                                         EDIT DATA




AccountManager

                 UI                           insert()




 SyncManager                  ContentResolver

                      notifyChange()          insert()




 SyncAdapter                  ContentProvider
Authenticator                         Sync architecture
                                                         EDIT DATA




AccountManager

                 UI                           insert()




 SyncManager                  ContentResolver

                      notifyChange()          insert()




 SyncAdapter                  ContentProvider
Authenticator                                      Sync architecture
                                                                      EDIT DATA




AccountManager

        getAccountsByType()
                              UI                           insert()




 SyncManager                               ContentResolver

                                   notifyChange()          insert()




 SyncAdapter                               ContentProvider
Authenticator                                              Sync architecture
                                                                                EDIT DATA




AccountManager

                  getAccountsByType()
                                        UI                           insert()




   SyncManager                                       ContentResolver

onPerformSync()                              notifyChange()          insert()




   SyncAdapter                                       ContentProvider
Authenticator             Sync architecture
                                     POST NEW DATA




AccountManager

                   UI

   SyncManager          ContentResolver

onPerformSync()




   SyncAdapter          ContentProvider
Authenticator                             Sync architecture
                                                     POST NEW DATA
                  getAuthToken()




AccountManager

                                   UI

   SyncManager                          ContentResolver

onPerformSync()




   SyncAdapter                          ContentProvider
Authenticator                                  Sync architecture
                                                           POST NEW DATA
                  getAuthToken()




AccountManager

                                        UI

   SyncManager                               ContentResolver
                                   query()
onPerformSync()                                          query()




   SyncAdapter                               ContentProvider
Authenticator                                         Sync architecture
                                                                  POST NEW DATA
                  getAuthToken()




AccountManager

                                               UI

   SyncManager                                      ContentResolver
                                          query()
onPerformSync()                                                 query()




   SyncAdapter                     POST
                                                    ContentProvider
Authenticator             Sync architecture
                                     GET NEW DATA




AccountManager

                   UI

   SyncManager          ContentResolver

onPerformSync()




   SyncAdapter          ContentProvider
Authenticator                             Sync architecture
                                                     GET NEW DATA
                  getAuthToken()




AccountManager

                                   UI

   SyncManager                          ContentResolver

onPerformSync()




   SyncAdapter                          ContentProvider
Authenticator                                   Sync architecture
                                                           GET NEW DATA
                  getAuthToken()




AccountManager

                                         UI

   SyncManager                                ContentResolver

onPerformSync()




   SyncAdapter                     GET
                                              ContentProvider
Authenticator                                             Sync architecture
                                                                     GET NEW DATA
                  getAuthToken()




AccountManager

                                             UI

   SyncManager                                      ContentResolver
                                     applyBatch()
onPerformSync()

                                                     applyBatch()




   SyncAdapter                     GET
                                                    ContentProvider
Authenticator                                             Sync architecture
                                                                       GET NEW DATA
                  getAuthToken()




AccountManager

                                             UI

   SyncManager                                      ContentResolver
                                     applyBatch()
onPerformSync()                                                     notifyChange()

                                                     applyBatch()




   SyncAdapter                     GET
                                                    ContentProvider
Authenticator                                               Sync architecture
                                                                            GET NEW DATA
                  getAuthToken()




AccountManager

                                                    onLoaderFinished()
                                             UI

   SyncManager                                      ContentResolver
                                     applyBatch()
onPerformSync()                                                          notifyChange()

                                                       applyBatch()




   SyncAdapter                     GET
                                                    ContentProvider
Authenticator             Sync architecture
                            WIN #1: NO REMOTE I/O IN UI




AccountManager

                 UI

 SyncManager          ContentResolver



 SyncAdapter          ContentProvider
Authenticator             Sync architecture
                             WIN #2: SYNC SCHEDULING




AccountManager

                 UI

 SyncManager          ContentResolver



 SyncAdapter          ContentProvider
Sync     ON ANDROID




   OVERVIEW                ARCHITECTURE

CONTENT PROVIDER         PITFALLS & PROTIPS
IDs in ContentProvider URIs


      content://com.futuresimple.krakdroid.Provider/datasets/1
IDs in ContentProvider URIs


      content://com.futuresimple.krakdroid.Provider/datasets/1




  Plan A: Use local IDs! (BaseColumns._ID)
IDs in ContentProvider URIs


      content://com.futuresimple.krakdroid.Provider/datasets/1




  Plan A: Use local IDs! (BaseColumns._ID)



  ISSUE: still need server-side IDs for relations
IDs in ContentProvider URIs


      content://com.futuresimple.krakdroid.Provider/datasets/1




  Plan A: Use local IDs! (BaseColumns._ID)



  ISSUE: still need server-side IDs for relations
  ISSUE: conversions between server and local IDs
IDs in ContentProvider URIs


   content://com.futuresimple.krakdroid.Provider/datasets/15002900




  Plan B: OK, use server-side IDs!
IDs in ContentProvider URIs


   content://com.futuresimple.krakdroid.Provider/datasets/15002900




  Plan B: OK, use server-side IDs!



  ISSUE: what about offline mode?
IDs in ContentProvider URIs


  content://com.futuresimple.krakdroid.Provider/datasets/-42
  content://com.futuresimple.krakdroid.Provider/datasets/15002900


  Plan C: OK, let’s mix things up!
IDs in ContentProvider URIs


  content://com.futuresimple.krakdroid.Provider/datasets/-42
  content://com.futuresimple.krakdroid.Provider/datasets/15002900


  Plan C: OK, let’s mix things up!



  ISSUE: very tricky implementation
IDs in ContentProvider URIs


     content://com.futuresimple.krakdroid.Provider/datasets/GUID




  Plan D: GUID
IDs in ContentProvider URIs


     content://com.futuresimple.krakdroid.Provider/datasets/GUID




  Plan D: GUID



  ISSUE: needs support on the backend
ContentResolver requestSync() vs. notifyChange()




      requestSync(account, authority, extras)

      notifyChange(uri, observer, syncToNetwork)
ContentResolver requestSync() vs. notifyChange()




      requestSync(account, authority, extras)

      notifyChange(uri, observer, syncToNetwork)
Deleting an account




      From your app

      From system settings

      From 3rd party app
Deleting an account




      From your app
                             “Where should I
      From system settings     perform user
                              data cleanup?”
      From 3rd party app
Deleting an account




  @Override getAccountRemovalAllowed()
Deleting an account




  @Override getAccountRemovalAllowed()



  CONS: depends on current Settings implementation.
  PROS: exactly the thing you need.
Deleting an account



  <receiver
      android:name=".auth.AccountBroadcastReceiver"
      android:enabled="true" >
      <intent-filter>
          <action android:name="android.accounts.LOGIN_ACCOUNTS_CHANGED" />
      </intent-filter>
  </receiver>
Deleting an account



  <receiver
      android:name=".auth.AccountBroadcastReceiver"
      android:enabled="true" >
      <intent-filter>
          <action android:name="android.accounts.LOGIN_ACCOUNTS_CHANGED" />
      </intent-filter>
  </receiver>




  CONS: only info about existing accounts.
  PROS: peace of mind.
Sync lifecycle


   Happy case:
Sync lifecycle


   Happy case:




            requestSync()
Sync lifecycle


   Happy case:


                    onPerformSync()

            requestSync()
Sync lifecycle


   Happy case:


                    onPerformSync()

            requestSync()   onStatusChanged()
Sync lifecycle


   Not-so-happy case:


                    onPerformSync()

            requestSync()   onStatusChanged()
Sync lifecycle


   Not-so-happy case:


                   onPerformSync()

   requestSync()           onStatusChanged()
Sync lifecycle


   Not-so-happy case:


                   onPerformSync()

   requestSync()           cancelSync()
                                +
                        onStatusChanged()
Futureproof your sync
Futureproof your sync



  1. Be lenient on GET
Futureproof your sync



  1. Be lenient on GET
  2. Be strict on POST
Futureproof your sync



  1. Be lenient on GET
  2. Be strict on POST
  3. Have resync in v1.0
?
Thanks.

Más contenido relacionado

La actualidad más candente

Azure AD B2C Webinar Series: Identity Protocols OIDC and OAuth2 part 1
Azure AD B2C Webinar Series: Identity Protocols OIDC and OAuth2 part 1Azure AD B2C Webinar Series: Identity Protocols OIDC and OAuth2 part 1
Azure AD B2C Webinar Series: Identity Protocols OIDC and OAuth2 part 1Vinu Gunasekaran
 
(MBL401) Social Logins for Mobile Apps with Amazon Cognito | AWS re:Invent 2014
(MBL401) Social Logins for Mobile Apps with Amazon Cognito | AWS re:Invent 2014(MBL401) Social Logins for Mobile Apps with Amazon Cognito | AWS re:Invent 2014
(MBL401) Social Logins for Mobile Apps with Amazon Cognito | AWS re:Invent 2014Amazon Web Services
 
Microsoft Graph developer community call-March 2020
Microsoft Graph developer community call-March 2020Microsoft Graph developer community call-March 2020
Microsoft Graph developer community call-March 2020Microsoft 365 Developer
 
Integrating an App with Amazon Web Services SimpleDB - A Matter of Choices
Integrating an App with Amazon Web Services SimpleDB - A Matter of ChoicesIntegrating an App with Amazon Web Services SimpleDB - A Matter of Choices
Integrating an App with Amazon Web Services SimpleDB - A Matter of ChoicesMark Maslyn
 
Azure AD B2C Webinar Series: Custom Policies Part 1
Azure AD B2C Webinar Series: Custom Policies Part 1Azure AD B2C Webinar Series: Custom Policies Part 1
Azure AD B2C Webinar Series: Custom Policies Part 1Vinu Gunasekaran
 
Deep Dive on Amazon Cognito - DevDay Austin 2017
Deep Dive on Amazon Cognito - DevDay Austin 2017Deep Dive on Amazon Cognito - DevDay Austin 2017
Deep Dive on Amazon Cognito - DevDay Austin 2017Amazon Web Services
 
Building Mobile Apps on AWS at Websummit Diublin
Building Mobile Apps on AWS at Websummit DiublinBuilding Mobile Apps on AWS at Websummit Diublin
Building Mobile Apps on AWS at Websummit DiublinAmazon Web Services
 
Managing Identity and Securing Your Mobile and Web Applications with Amazon C...
Managing Identity and Securing Your Mobile and Web Applications with Amazon C...Managing Identity and Securing Your Mobile and Web Applications with Amazon C...
Managing Identity and Securing Your Mobile and Web Applications with Amazon C...Amazon Web Services
 
Build Your Mobile App Faster with AWS Mobile Services
Build Your Mobile App Faster with AWS Mobile ServicesBuild Your Mobile App Faster with AWS Mobile Services
Build Your Mobile App Faster with AWS Mobile ServicesAmazon Web Services
 
Azure AD B2C Webinar Series: Custom Policies Part 3 Troubleshooting
Azure AD B2C Webinar Series: Custom Policies Part 3 TroubleshootingAzure AD B2C Webinar Series: Custom Policies Part 3 Troubleshooting
Azure AD B2C Webinar Series: Custom Policies Part 3 TroubleshootingVinu Gunasekaran
 
Deep Dive on User Sign-up Sign-in with Amazon Cognito - AWS Online Tech Talks
Deep Dive on User Sign-up Sign-in with Amazon Cognito - AWS Online Tech TalksDeep Dive on User Sign-up Sign-in with Amazon Cognito - AWS Online Tech Talks
Deep Dive on User Sign-up Sign-in with Amazon Cognito - AWS Online Tech TalksAmazon Web Services
 
Authentication and Identity with Amazon Cognito
Authentication and Identity with Amazon CognitoAuthentication and Identity with Amazon Cognito
Authentication and Identity with Amazon CognitoAmazon Web Services
 
Authentication & Authorization for Connected Mobile & Web Applications using ...
Authentication & Authorization for Connected Mobile & Web Applications using ...Authentication & Authorization for Connected Mobile & Web Applications using ...
Authentication & Authorization for Connected Mobile & Web Applications using ...Amazon Web Services
 
24032022 Zero Trust for Developers Pub.pdf
24032022 Zero Trust for Developers Pub.pdf24032022 Zero Trust for Developers Pub.pdf
24032022 Zero Trust for Developers Pub.pdfTomasz Kopacz
 
Implement Authorization in your Apps with Microsoft identity platform-June 2020
Implement Authorization in your Apps with Microsoft identity platform-June 2020Implement Authorization in your Apps with Microsoft identity platform-June 2020
Implement Authorization in your Apps with Microsoft identity platform-June 2020Microsoft 365 Developer
 
Office 365 api vs share point app model
Office 365 api vs share point app modelOffice 365 api vs share point app model
Office 365 api vs share point app modelBIWUG
 
Serverless Patterns: “No server is easier to manage than no server” - AWS Sec...
Serverless Patterns: “No server is easier to manage than no server” - AWS Sec...Serverless Patterns: “No server is easier to manage than no server” - AWS Sec...
Serverless Patterns: “No server is easier to manage than no server” - AWS Sec...Amazon Web Services
 
Cloud-powered Cross-platform Mobile Apps on AWS
Cloud-powered Cross-platform Mobile Apps on AWSCloud-powered Cross-platform Mobile Apps on AWS
Cloud-powered Cross-platform Mobile Apps on AWSDanilo Poccia
 

La actualidad más candente (20)

Azure AD B2C Webinar Series: Identity Protocols OIDC and OAuth2 part 1
Azure AD B2C Webinar Series: Identity Protocols OIDC and OAuth2 part 1Azure AD B2C Webinar Series: Identity Protocols OIDC and OAuth2 part 1
Azure AD B2C Webinar Series: Identity Protocols OIDC and OAuth2 part 1
 
(MBL401) Social Logins for Mobile Apps with Amazon Cognito | AWS re:Invent 2014
(MBL401) Social Logins for Mobile Apps with Amazon Cognito | AWS re:Invent 2014(MBL401) Social Logins for Mobile Apps with Amazon Cognito | AWS re:Invent 2014
(MBL401) Social Logins for Mobile Apps with Amazon Cognito | AWS re:Invent 2014
 
Microsoft Graph developer community call-March 2020
Microsoft Graph developer community call-March 2020Microsoft Graph developer community call-March 2020
Microsoft Graph developer community call-March 2020
 
Integrating an App with Amazon Web Services SimpleDB - A Matter of Choices
Integrating an App with Amazon Web Services SimpleDB - A Matter of ChoicesIntegrating an App with Amazon Web Services SimpleDB - A Matter of Choices
Integrating an App with Amazon Web Services SimpleDB - A Matter of Choices
 
Azure AD B2C Webinar Series: Custom Policies Part 1
Azure AD B2C Webinar Series: Custom Policies Part 1Azure AD B2C Webinar Series: Custom Policies Part 1
Azure AD B2C Webinar Series: Custom Policies Part 1
 
Deep Dive on Amazon Cognito - DevDay Austin 2017
Deep Dive on Amazon Cognito - DevDay Austin 2017Deep Dive on Amazon Cognito - DevDay Austin 2017
Deep Dive on Amazon Cognito - DevDay Austin 2017
 
Building Mobile Apps on AWS at Websummit Diublin
Building Mobile Apps on AWS at Websummit DiublinBuilding Mobile Apps on AWS at Websummit Diublin
Building Mobile Apps on AWS at Websummit Diublin
 
Managing Identity and Securing Your Mobile and Web Applications with Amazon C...
Managing Identity and Securing Your Mobile and Web Applications with Amazon C...Managing Identity and Securing Your Mobile and Web Applications with Amazon C...
Managing Identity and Securing Your Mobile and Web Applications with Amazon C...
 
Build Your Mobile App Faster with AWS Mobile Services
Build Your Mobile App Faster with AWS Mobile ServicesBuild Your Mobile App Faster with AWS Mobile Services
Build Your Mobile App Faster with AWS Mobile Services
 
Azure AD B2C Webinar Series: Custom Policies Part 3 Troubleshooting
Azure AD B2C Webinar Series: Custom Policies Part 3 TroubleshootingAzure AD B2C Webinar Series: Custom Policies Part 3 Troubleshooting
Azure AD B2C Webinar Series: Custom Policies Part 3 Troubleshooting
 
Deep Dive on User Sign-up Sign-in with Amazon Cognito - AWS Online Tech Talks
Deep Dive on User Sign-up Sign-in with Amazon Cognito - AWS Online Tech TalksDeep Dive on User Sign-up Sign-in with Amazon Cognito - AWS Online Tech Talks
Deep Dive on User Sign-up Sign-in with Amazon Cognito - AWS Online Tech Talks
 
Authentication and Identity with Amazon Cognito
Authentication and Identity with Amazon CognitoAuthentication and Identity with Amazon Cognito
Authentication and Identity with Amazon Cognito
 
Authentication & Authorization for Connected Mobile & Web Applications using ...
Authentication & Authorization for Connected Mobile & Web Applications using ...Authentication & Authorization for Connected Mobile & Web Applications using ...
Authentication & Authorization for Connected Mobile & Web Applications using ...
 
24032022 Zero Trust for Developers Pub.pdf
24032022 Zero Trust for Developers Pub.pdf24032022 Zero Trust for Developers Pub.pdf
24032022 Zero Trust for Developers Pub.pdf
 
Implement Authorization in your Apps with Microsoft identity platform-June 2020
Implement Authorization in your Apps with Microsoft identity platform-June 2020Implement Authorization in your Apps with Microsoft identity platform-June 2020
Implement Authorization in your Apps with Microsoft identity platform-June 2020
 
Office 365 api vs share point app model
Office 365 api vs share point app modelOffice 365 api vs share point app model
Office 365 api vs share point app model
 
Serverless Patterns: “No server is easier to manage than no server” - AWS Sec...
Serverless Patterns: “No server is easier to manage than no server” - AWS Sec...Serverless Patterns: “No server is easier to manage than no server” - AWS Sec...
Serverless Patterns: “No server is easier to manage than no server” - AWS Sec...
 
Amazon Cognito
Amazon CognitoAmazon Cognito
Amazon Cognito
 
Amazon Cognito Deep Dive
Amazon Cognito Deep DiveAmazon Cognito Deep Dive
Amazon Cognito Deep Dive
 
Cloud-powered Cross-platform Mobile Apps on AWS
Cloud-powered Cross-platform Mobile Apps on AWSCloud-powered Cross-platform Mobile Apps on AWS
Cloud-powered Cross-platform Mobile Apps on AWS
 

Similar a How to Sync Data on Android

Build Your Mobile App Faster with AWS Mobile Services (Part 1 - AWS)
Build Your Mobile App Faster with AWS Mobile Services (Part 1 - AWS)Build Your Mobile App Faster with AWS Mobile Services (Part 1 - AWS)
Build Your Mobile App Faster with AWS Mobile Services (Part 1 - AWS)Amazon Web Services
 
Build high performing mobile apps, faster with AWS
Build high performing mobile apps, faster with AWSBuild high performing mobile apps, faster with AWS
Build high performing mobile apps, faster with AWSShiva Narayanaswamy
 
Build and Deploy Your Mobile Games
Build and Deploy Your Mobile Games Build and Deploy Your Mobile Games
Build and Deploy Your Mobile Games Amazon Web Services
 
Lightweight Xtext Editors as SWT Widgets
Lightweight Xtext Editors as SWT WidgetsLightweight Xtext Editors as SWT Widgets
Lightweight Xtext Editors as SWT Widgetsmeysholdt
 
Introduction to Microservices by Jim Tran, Principal Solutions Architect, AWS
Introduction to Microservices by Jim Tran, Principal Solutions Architect, AWSIntroduction to Microservices by Jim Tran, Principal Solutions Architect, AWS
Introduction to Microservices by Jim Tran, Principal Solutions Architect, AWSAmazon Web Services
 
MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...
MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...
MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...MongoDB
 
Faites évoluer votre accès aux données avec MongoDB Stitch
Faites évoluer votre accès aux données avec MongoDB StitchFaites évoluer votre accès aux données avec MongoDB Stitch
Faites évoluer votre accès aux données avec MongoDB StitchMongoDB
 
Connect + Docker + AWS = Bitbucket Pipelines
Connect + Docker + AWS = Bitbucket PipelinesConnect + Docker + AWS = Bitbucket Pipelines
Connect + Docker + AWS = Bitbucket PipelinesAtlassian
 
Dev suite integration
Dev suite integrationDev suite integration
Dev suite integrationiemu
 
(MBL302) Mastering Synchronization Across Mobile Devices, Login Providers, an...
(MBL302) Mastering Synchronization Across Mobile Devices, Login Providers, an...(MBL302) Mastering Synchronization Across Mobile Devices, Login Providers, an...
(MBL302) Mastering Synchronization Across Mobile Devices, Login Providers, an...Amazon Web Services
 
Itb 2021 - Bulding Quick APIs by Gavin Pickin
Itb 2021 - Bulding Quick APIs by Gavin PickinItb 2021 - Bulding Quick APIs by Gavin Pickin
Itb 2021 - Bulding Quick APIs by Gavin PickinGavin Pickin
 
BlackBerry10 apps with Adobe AIR & Apache Flex - BlackBerry JAM Europe
BlackBerry10 apps with Adobe AIR & Apache Flex - BlackBerry JAM EuropeBlackBerry10 apps with Adobe AIR & Apache Flex - BlackBerry JAM Europe
BlackBerry10 apps with Adobe AIR & Apache Flex - BlackBerry JAM EuropeMariano Carrizo
 
Build Your Mobile App Faster with AWS Mobile Services
Build Your Mobile App Faster with AWS Mobile ServicesBuild Your Mobile App Faster with AWS Mobile Services
Build Your Mobile App Faster with AWS Mobile ServicesAmazon Web Services
 
Deep Dive into SpaceONE
Deep Dive into SpaceONEDeep Dive into SpaceONE
Deep Dive into SpaceONEChoonho Son
 
Pycon Korea 2018-Sanic을 활용하여 Microservice 구축하기-이재면
Pycon Korea 2018-Sanic을 활용하여 Microservice 구축하기-이재면Pycon Korea 2018-Sanic을 활용하여 Microservice 구축하기-이재면
Pycon Korea 2018-Sanic을 활용하여 Microservice 구축하기-이재면jaemyun lee
 
Exam 70-488 Developing Microsoft SharePoint Server 2013 Core Solutions Learni...
Exam 70-488 Developing Microsoft SharePoint Server 2013 Core Solutions Learni...Exam 70-488 Developing Microsoft SharePoint Server 2013 Core Solutions Learni...
Exam 70-488 Developing Microsoft SharePoint Server 2013 Core Solutions Learni...Mahmoud Hamed Mahmoud
 

Similar a How to Sync Data on Android (20)

Build Your Mobile App Faster with AWS Mobile Services (Part 1 - AWS)
Build Your Mobile App Faster with AWS Mobile Services (Part 1 - AWS)Build Your Mobile App Faster with AWS Mobile Services (Part 1 - AWS)
Build Your Mobile App Faster with AWS Mobile Services (Part 1 - AWS)
 
Build high performing mobile apps, faster with AWS
Build high performing mobile apps, faster with AWSBuild high performing mobile apps, faster with AWS
Build high performing mobile apps, faster with AWS
 
Build and Deploy Your Mobile Games
Build and Deploy Your Mobile Games Build and Deploy Your Mobile Games
Build and Deploy Your Mobile Games
 
What's new in the July 2017 Update for Dynamics 365 - Developer features
What's new in the July 2017 Update for Dynamics 365 - Developer featuresWhat's new in the July 2017 Update for Dynamics 365 - Developer features
What's new in the July 2017 Update for Dynamics 365 - Developer features
 
Lightweight Xtext Editors as SWT Widgets
Lightweight Xtext Editors as SWT WidgetsLightweight Xtext Editors as SWT Widgets
Lightweight Xtext Editors as SWT Widgets
 
Introduction to Microservices by Jim Tran, Principal Solutions Architect, AWS
Introduction to Microservices by Jim Tran, Principal Solutions Architect, AWSIntroduction to Microservices by Jim Tran, Principal Solutions Architect, AWS
Introduction to Microservices by Jim Tran, Principal Solutions Architect, AWS
 
MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...
MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...
MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...
 
Faites évoluer votre accès aux données avec MongoDB Stitch
Faites évoluer votre accès aux données avec MongoDB StitchFaites évoluer votre accès aux données avec MongoDB Stitch
Faites évoluer votre accès aux données avec MongoDB Stitch
 
Connect + Docker + AWS = Bitbucket Pipelines
Connect + Docker + AWS = Bitbucket PipelinesConnect + Docker + AWS = Bitbucket Pipelines
Connect + Docker + AWS = Bitbucket Pipelines
 
ASP.NET Lecture 6
ASP.NET Lecture 6ASP.NET Lecture 6
ASP.NET Lecture 6
 
Dev suite integration
Dev suite integrationDev suite integration
Dev suite integration
 
(MBL302) Mastering Synchronization Across Mobile Devices, Login Providers, an...
(MBL302) Mastering Synchronization Across Mobile Devices, Login Providers, an...(MBL302) Mastering Synchronization Across Mobile Devices, Login Providers, an...
(MBL302) Mastering Synchronization Across Mobile Devices, Login Providers, an...
 
Introduction to Microservices
Introduction to MicroservicesIntroduction to Microservices
Introduction to Microservices
 
Itb 2021 - Bulding Quick APIs by Gavin Pickin
Itb 2021 - Bulding Quick APIs by Gavin PickinItb 2021 - Bulding Quick APIs by Gavin Pickin
Itb 2021 - Bulding Quick APIs by Gavin Pickin
 
BlackBerry10 apps with Adobe AIR & Apache Flex - BlackBerry JAM Europe
BlackBerry10 apps with Adobe AIR & Apache Flex - BlackBerry JAM EuropeBlackBerry10 apps with Adobe AIR & Apache Flex - BlackBerry JAM Europe
BlackBerry10 apps with Adobe AIR & Apache Flex - BlackBerry JAM Europe
 
Build Your Mobile App Faster with AWS Mobile Services
Build Your Mobile App Faster with AWS Mobile ServicesBuild Your Mobile App Faster with AWS Mobile Services
Build Your Mobile App Faster with AWS Mobile Services
 
Deep Dive into SpaceONE
Deep Dive into SpaceONEDeep Dive into SpaceONE
Deep Dive into SpaceONE
 
Pycon Korea 2018-Sanic을 활용하여 Microservice 구축하기-이재면
Pycon Korea 2018-Sanic을 활용하여 Microservice 구축하기-이재면Pycon Korea 2018-Sanic을 활용하여 Microservice 구축하기-이재면
Pycon Korea 2018-Sanic을 활용하여 Microservice 구축하기-이재면
 
App Modernization with Microsoft Azure
App Modernization with Microsoft AzureApp Modernization with Microsoft Azure
App Modernization with Microsoft Azure
 
Exam 70-488 Developing Microsoft SharePoint Server 2013 Core Solutions Learni...
Exam 70-488 Developing Microsoft SharePoint Server 2013 Core Solutions Learni...Exam 70-488 Developing Microsoft SharePoint Server 2013 Core Solutions Learni...
Exam 70-488 Developing Microsoft SharePoint Server 2013 Core Solutions Learni...
 

Último

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 

Último (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 

How to Sync Data on Android

  • 1. Sync ON ANDROID Jerzy Chalupski chalup jerzy@futuresimple.com
  • 2. What we do in general...
  • 3. What we do ALL THE TIME sync, sync, sync, sync
  • 4. Sync ON ANDROID OVERVIEW ARCHITECTURE CONTENT PROVIDER PITFALLS & PROTIPS
  • 5. Sync ON ANDROID OVERVIEW ARCHITECTURE CONTENT PROVIDER PITFALLS & PROTIPS
  • 6. Not exactly the fresh topic... „Developing Android REST client applications” by Virgil Dobjanschi @Google I/O 2010
  • 7. Not exactly the fresh topic... „Synchronizacja danych z serwisami webowymi w Androidzie” by Bartosz Filipowicz @KrakDroid 2011
  • 8. Not exactly the fresh topic... „Synchronizacja danych z serwisami webowymi w Androidzie” by Bartosz Filipowicz @KrakDroid 2011 ...but there is still much confusion
  • 9. AccountManager SyncManager UI Authenticator ContentProvider SyncAdapter ContentResolver
  • 10. „Wat? Why do I need to write all this crap, sync is just fetching data from server” typical reaction
  • 12. Sync provides data sharing offline mode
  • 13. Sync provides data sharing offline mode responsive UI
  • 14. Sync provides data sharing offline mode responsive UI GREAT UX
  • 15. Sync ON ANDROID OVERVIEW ARCHITECTURE CONTENT PROVIDER PITFALLS & PROTIPS
  • 16. ContentProvider 101: CRUD CREATE insert() READ query() UPDATE update() DELETE delete()
  • 17. ContentProvider 101: URI content://com.futuresimple.krakdroid.Provider/datasets/1
  • 18. ContentProvider 101: URI content://com.futuresimple.krakdroid.Provider/datasets/1
  • 19. ContentProvider 101: URI content://com.futuresimple.krakdroid.Provider/datasets/1
  • 20. ContentProvider 101: URI content://com.futuresimple.krakdroid.Provider/datasets/1
  • 21. ContentProvider 101: notifications content://com.futuresimple.krakdroid.Provider/datasets/1 content://com.futuresimple.krakdroid.Provider/solutions content://com.futuresimple.krakdroid.Provider/solutions/1 content://com.futuresimple.krakdroid.Provider/solutions/1/answers/1 content://com.futuresimple.krakdroid.Provider/solutions/1/answers/2 content://com.futuresimple.krakdroid.Provider/solutions/2/answers/1
  • 22. ContentProvider 101: notifications content://com.futuresimple.krakdroid.Provider/datasets/1 content://com.futuresimple.krakdroid.Provider/solutions content://com.futuresimple.krakdroid.Provider/solutions/1 content://com.futuresimple.krakdroid.Provider/solutions/1/answers/1 content://com.futuresimple.krakdroid.Provider/solutions/1/answers/2 content://com.futuresimple.krakdroid.Provider/solutions/2/answers/1 ContentResolver.notifyChange(“content:// com.futuresimple.krakdroid.Provider/datasets/1”);
  • 23. ContentProvider 101: notifications content://com.futuresimple.krakdroid.Provider/datasets/1 content://com.futuresimple.krakdroid.Provider/solutions content://com.futuresimple.krakdroid.Provider/solutions/1 content://com.futuresimple.krakdroid.Provider/solutions/1/answers/1 content://com.futuresimple.krakdroid.Provider/solutions/1/answers/2 content://com.futuresimple.krakdroid.Provider/solutions/2/answers/1 ContentResolver.notifyChange(“content:// com.futuresimple.krakdroid.Provider/solutions/1/answers/1”);
  • 24. Sync ON ANDROID OVERVIEW ARCHITECTURE CONTENT PROVIDER PITFALLS & PROTIPS
  • 25. AccountManager SyncManager UI Authenticator ContentProvider SyncAdapter ContentResolver
  • 26. Authenticator Sync architecture CREATING NEW ACCOUNT AccountManager addAccount() UI SyncManager ContentResolver SyncAdapter ContentProvider
  • 27. Authenticator Sync architecture CREATING NEW ACCOUNT addAccount() AccountManager addAccount() UI SyncManager ContentResolver SyncAdapter ContentProvider
  • 28. Authenticator Sync architecture CREATING NEW ACCOUNT addAccount() AccountManager addAccount() UI SyncManager ContentResolver SyncAdapter ContentProvider
  • 29. Authenticator Sync architecture SHOW SYNCED DATA AccountManager UI query() SyncManager ContentResolver query() SyncAdapter ContentProvider
  • 30. Authenticator Sync architecture REQUEST SYNC AccountManager getAccountsByType() UI SyncManager ContentResolver SyncAdapter ContentProvider
  • 31. Authenticator Sync architecture REQUEST SYNC AccountManager getAccountsByType() UI requestSync() SyncManager ContentResolver SyncAdapter ContentProvider
  • 32. Authenticator Sync architecture REQUEST SYNC AccountManager getAccountsByType() UI requestSync() SyncManager ContentResolver onPerformSync() SyncAdapter ContentProvider
  • 33. Authenticator Sync architecture EDIT DATA AccountManager UI insert() SyncManager ContentResolver insert() SyncAdapter ContentProvider
  • 34. Authenticator Sync architecture EDIT DATA AccountManager UI insert() SyncManager ContentResolver notifyChange() insert() SyncAdapter ContentProvider
  • 35. Authenticator Sync architecture EDIT DATA AccountManager UI insert() SyncManager ContentResolver notifyChange() insert() SyncAdapter ContentProvider
  • 36. Authenticator Sync architecture EDIT DATA AccountManager getAccountsByType() UI insert() SyncManager ContentResolver notifyChange() insert() SyncAdapter ContentProvider
  • 37. Authenticator Sync architecture EDIT DATA AccountManager getAccountsByType() UI insert() SyncManager ContentResolver onPerformSync() notifyChange() insert() SyncAdapter ContentProvider
  • 38. Authenticator Sync architecture POST NEW DATA AccountManager UI SyncManager ContentResolver onPerformSync() SyncAdapter ContentProvider
  • 39. Authenticator Sync architecture POST NEW DATA getAuthToken() AccountManager UI SyncManager ContentResolver onPerformSync() SyncAdapter ContentProvider
  • 40. Authenticator Sync architecture POST NEW DATA getAuthToken() AccountManager UI SyncManager ContentResolver query() onPerformSync() query() SyncAdapter ContentProvider
  • 41. Authenticator Sync architecture POST NEW DATA getAuthToken() AccountManager UI SyncManager ContentResolver query() onPerformSync() query() SyncAdapter POST ContentProvider
  • 42. Authenticator Sync architecture GET NEW DATA AccountManager UI SyncManager ContentResolver onPerformSync() SyncAdapter ContentProvider
  • 43. Authenticator Sync architecture GET NEW DATA getAuthToken() AccountManager UI SyncManager ContentResolver onPerformSync() SyncAdapter ContentProvider
  • 44. Authenticator Sync architecture GET NEW DATA getAuthToken() AccountManager UI SyncManager ContentResolver onPerformSync() SyncAdapter GET ContentProvider
  • 45. Authenticator Sync architecture GET NEW DATA getAuthToken() AccountManager UI SyncManager ContentResolver applyBatch() onPerformSync() applyBatch() SyncAdapter GET ContentProvider
  • 46. Authenticator Sync architecture GET NEW DATA getAuthToken() AccountManager UI SyncManager ContentResolver applyBatch() onPerformSync() notifyChange() applyBatch() SyncAdapter GET ContentProvider
  • 47. Authenticator Sync architecture GET NEW DATA getAuthToken() AccountManager onLoaderFinished() UI SyncManager ContentResolver applyBatch() onPerformSync() notifyChange() applyBatch() SyncAdapter GET ContentProvider
  • 48. Authenticator Sync architecture WIN #1: NO REMOTE I/O IN UI AccountManager UI SyncManager ContentResolver SyncAdapter ContentProvider
  • 49. Authenticator Sync architecture WIN #2: SYNC SCHEDULING AccountManager UI SyncManager ContentResolver SyncAdapter ContentProvider
  • 50. Sync ON ANDROID OVERVIEW ARCHITECTURE CONTENT PROVIDER PITFALLS & PROTIPS
  • 51. IDs in ContentProvider URIs content://com.futuresimple.krakdroid.Provider/datasets/1
  • 52. IDs in ContentProvider URIs content://com.futuresimple.krakdroid.Provider/datasets/1 Plan A: Use local IDs! (BaseColumns._ID)
  • 53. IDs in ContentProvider URIs content://com.futuresimple.krakdroid.Provider/datasets/1 Plan A: Use local IDs! (BaseColumns._ID) ISSUE: still need server-side IDs for relations
  • 54. IDs in ContentProvider URIs content://com.futuresimple.krakdroid.Provider/datasets/1 Plan A: Use local IDs! (BaseColumns._ID) ISSUE: still need server-side IDs for relations ISSUE: conversions between server and local IDs
  • 55. IDs in ContentProvider URIs content://com.futuresimple.krakdroid.Provider/datasets/15002900 Plan B: OK, use server-side IDs!
  • 56. IDs in ContentProvider URIs content://com.futuresimple.krakdroid.Provider/datasets/15002900 Plan B: OK, use server-side IDs! ISSUE: what about offline mode?
  • 57. IDs in ContentProvider URIs content://com.futuresimple.krakdroid.Provider/datasets/-42 content://com.futuresimple.krakdroid.Provider/datasets/15002900 Plan C: OK, let’s mix things up!
  • 58. IDs in ContentProvider URIs content://com.futuresimple.krakdroid.Provider/datasets/-42 content://com.futuresimple.krakdroid.Provider/datasets/15002900 Plan C: OK, let’s mix things up! ISSUE: very tricky implementation
  • 59. IDs in ContentProvider URIs content://com.futuresimple.krakdroid.Provider/datasets/GUID Plan D: GUID
  • 60. IDs in ContentProvider URIs content://com.futuresimple.krakdroid.Provider/datasets/GUID Plan D: GUID ISSUE: needs support on the backend
  • 61. ContentResolver requestSync() vs. notifyChange() requestSync(account, authority, extras) notifyChange(uri, observer, syncToNetwork)
  • 62. ContentResolver requestSync() vs. notifyChange() requestSync(account, authority, extras) notifyChange(uri, observer, syncToNetwork)
  • 63. Deleting an account From your app From system settings From 3rd party app
  • 64. Deleting an account From your app “Where should I From system settings perform user data cleanup?” From 3rd party app
  • 65. Deleting an account @Override getAccountRemovalAllowed()
  • 66. Deleting an account @Override getAccountRemovalAllowed() CONS: depends on current Settings implementation. PROS: exactly the thing you need.
  • 67. Deleting an account <receiver android:name=".auth.AccountBroadcastReceiver" android:enabled="true" > <intent-filter> <action android:name="android.accounts.LOGIN_ACCOUNTS_CHANGED" /> </intent-filter> </receiver>
  • 68. Deleting an account <receiver android:name=".auth.AccountBroadcastReceiver" android:enabled="true" > <intent-filter> <action android:name="android.accounts.LOGIN_ACCOUNTS_CHANGED" /> </intent-filter> </receiver> CONS: only info about existing accounts. PROS: peace of mind.
  • 69. Sync lifecycle Happy case:
  • 70. Sync lifecycle Happy case: requestSync()
  • 71. Sync lifecycle Happy case: onPerformSync() requestSync()
  • 72. Sync lifecycle Happy case: onPerformSync() requestSync() onStatusChanged()
  • 73. Sync lifecycle Not-so-happy case: onPerformSync() requestSync() onStatusChanged()
  • 74. Sync lifecycle Not-so-happy case: onPerformSync() requestSync() onStatusChanged()
  • 75. Sync lifecycle Not-so-happy case: onPerformSync() requestSync() cancelSync() + onStatusChanged()
  • 77. Futureproof your sync 1. Be lenient on GET
  • 78. Futureproof your sync 1. Be lenient on GET 2. Be strict on POST
  • 79. Futureproof your sync 1. Be lenient on GET 2. Be strict on POST 3. Have resync in v1.0
  • 80. ?
  • 81.
  • 82.