Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

Hadas Dahan
Hadas Dahan
1,213 Points

Sync data between sqlite and MS Sql server

What is the best way to sync data between sqlite DB and SQL server DB on a remote server. I tried using async tasks calling web services, but I'm having troubles with calling the async threads in a loop on all rows which need to be copied to the server. I was wondering what was the best way to sync data from android to the server.

Thank you,

1 Answer

Your best choice is to use a SyncAdapter on the android platform. Here's a brief.

The SyncAdapter is an android component which schedules syncs from mobile to server on a periodic bases set by you. You are guaranteed to have an internet connection when it runs. All you need to do is add your logic to upload/download/update data on both the server and client (mobile app). If there's no internet connection your code will run on the next connection as it will be in a queue. I recently created one. Starting from here on google developers

http://developer.android.com/training/sync-adapters/creating-authenticator.html

It's very useful and very efficient!

Hadas Dahan
Hadas Dahan
1,213 Points

Thanks, I'll give it a try!