0

I am developing an android application, It has a server side too. In server side i am using mysql and php. I want to sync the data between mysql and sqlite.

How to do this ?

1 Answer 1

1

Method #1 : Using Sync Adapter

You can sync the device and a server using a Sync Adapter in android. See the developer documents.

Creating a Sync Adapter

Basically this requires you to extend your class with AbstractThreadedSyncAdapter where you write your sync logic, create some xml files and a Content Provider to share your data.

With this method you dont have to handle network availability. All the work is basically done by android.

This is an android sample I wrote using AbstractThreadedSyncAdapter to sync data between device and a server. This is its server side written in Java using Servlet. Please have a look.

Method #2 : Using a simple API

If you don't need all that complexity, you can just create an API that both accepts the data from the device and outputs the data on the MySQL database. You will need to write some logic to sync the data.

Good luck :)

Sign up to request clarification or add additional context in comments.

2 Comments

I am using php in webside. Is there any examples for that ? where you are specifying the db ?
No I'm afraid I don't have anything related to PHP. I have used JDBC with derby database in the server side. I'm sure you can adapt the logic for PHP/MySQL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.