Click here to Skip to main content
15,884,099 members
Articles / Mobile Apps / Android

Simple Sync Apps

Rate me:
Please Sign up or sign in to vote.
4.86/5 (7 votes)
26 Feb 2013CPOL3 min read 23.1K   1.5K   11   3
Synchronizing between Android and desktop

About the Download

The download file is very big, the reason is there are two projects contained inside the zip file. One is a desktop application and the other one is an Android application. 

Introduction 

I began to learn programming half of a years ago and I began to write this application about a month ago. I began from 0 knowledge to network and server. So I couldn’t make sure that I have written a very perfect program. But, this application does exactly what I need for synchronizing between Android and desktop. It is how the application looks like. Check it out with the following video:

How It Works

sync_pic1

The picture above shows how the data is transferred. Database server is a bridge to allow data move from Android to desktop and move from desktop to Android. That’s all, simple right! Of course, that’s other way such as cloud computing or others. Based on my knowledge, this is an easier way I know.

Develop Environment

My development environment is Java JDK version 1.7.0_13, Eclipse SDK (Juno version 4.2.1), XAMPP 1.8.1, MySQL Connector/J 5.1.23, android 4.2. Because every software I used to develop this application is open-source, I spent zero cost on this project.

Program Flow Chart

sync_pic2

The flow chart above shows how data is passing through between Android and desktop.
When user presses a button on UI thread to ask Android, read what desktop has written, Android will begin access to MySQL server. In server side, two PHP files (update database and read database PHP files) is created and located at htdocs. After Android, there will be success to access into server, then Android will begin searching the PHP files requested (either update or read PHP files) through HTTP protocol.

Request asks for read database PHP file to work. When read database PHP file is executed, PHP file will begin its work by logging in to database and retrieving the data requested what desktop has written into database. Then, PHP gets the data it wants from database, it will pass it again to Android and Android will get the data and put it on UI thread to show user what data was retrieved from database. If the desktop asks for what Android has written, it (desktop) will do exactly the same things as what Android did. Desktop will go into database adapter request for data it wants. Then database adapter will log in to database server through Java-MySQL connector and search for what Android has written into database. After database adapter gets what it wants, it will pass the data to desktop and desktop will put it on screen to show user what data it (desktop) got.

Source Code

  • mysqlAndroid is an Android project. Inside this project, there are three Java source code (JsonParser, JsonPost and MainThread).
  • JsonParser.java contains the HttpGet method. There is no input data to URL, only retrieve data from the PHP file.
  • JsonPost.java contains the HttpPost method. This method allows data post into PHP file.
  • MainThread.java is a UI thread work that calls the button or textView method allows user talk with machine.
  • mysqlDesktop is a Java Swing project. Inside this project, there are three Java source code files and one external jar that is DatabaseAdapter.java, jConnector.java, and MainFrame.java, and mysql-java Connector.
  • jConnector.java contains the source code that allows Java project to connect to MySQL database.
  • DatabaseAdapter.java is used to make database work get easier to carry it out.
  • MainFrame.java is a source code that allows user to talk with device through Windows Form.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Japan Japan
Hi! Thank you everyone who reading my article. My major is electronic and programming. Right now I am doing foreign study at Japan. I will like sharing to everyone with my works and if you do interesting with my works, please leave you comment on my blog. Any comments is welcoming.

Comments and Discussions

 
Questionother ways Pin
Kasra Ahmadi27-Oct-14 4:16
Kasra Ahmadi27-Oct-14 4:16 
AnswerRe: other ways Pin
Edison Heng27-Oct-14 19:25
Edison Heng27-Oct-14 19:25 
GeneralMy vote of 5 Pin
Ștefan-Mihai MOGA11-Mar-13 21:50
professionalȘtefan-Mihai MOGA11-Mar-13 21:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.