0

I need to send bulk of data to my database on server from Android app, and need to sync it periodically. I went through Sync Adapters sample code on Android Developer's website, but couldn't get the concept and usage.

I need help regarding:

  1. how it can be used for server database interaction?

  2. can a single Sync adapter be used to synchronize data in multiple tables, at once?

halfer
  • 19,824
  • 17
  • 99
  • 186
pratiti-systematix
  • 792
  • 11
  • 28

1 Answers1

1

I start working few days ago on SyncAdapter, SyncService, I can answer to your second question by YES you can sync multiple tables through a ContentProvider implementation.

Your first question has a large scope that I think it will take time to cover. In your onPermformSync, you could make HTTP request (PUT / GET etc.) to your server to synchronize local and server information.

I hope my light knowledge on the subject will be helpful !

Arpit Kulsreshtha
  • 2,452
  • 2
  • 26
  • 52
tontonGG
  • 48
  • 5
  • Thanks for answering, could you help me with a code sample for the same? That would be great! – pratiti-systematix Nov 12 '14 at 13:26
  • 1
    You can read this great article which help me a lot : http://udinic.wordpress.com/2013/07/24/write-your-own-android-sync-adapter/ – tontonGG Nov 12 '14 at 13:50
  • Thanks a lot. It helped :) Very nice tutorial. – pratiti-systematix Nov 13 '14 at 09:04
  • Can you please tell me, how can sync multiple database tables with a single sync adapter? – pratiti-systematix Nov 13 '14 at 11:21
  • Well, in my project, I use a content provider (which is the interface between my multiple SQLite tables). From my `onPerformSync` I call content provider method (`query`, `insert`, `delete`, `update`). These methods use URI to know which table to access. But you can bypass the content provider (until I suggest you to use it because it brings structure in your application, see http://www.grokkingandroid.com/android-tutorial-writing-your-own-content-provider/) – tontonGG Nov 14 '14 at 07:52