2013年2月23日土曜日

Simple Sync Apps

About Download

Click here to download. The zip file contains 2 projects and 1 php file.

Introduction

I begin to learn programming is still half of a years ago and I begin to write this application is about one months ago. Begin from 0 knowledge to network and server. So I couldn’t make sure that I have wrote a very perfect program. But, this application do exactly what I need for that is synchronizing between android and desktop. 
It is how it’s look like. Check it out with the following video.



How it's work

sync_pic1Picture 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 easier way I know.

Develop Environment

My develop 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 a zero cost on this project.

Program Flow Chart


sync_pic2

Flow chart beside shows how data is passing through between android and desktop.
When user press a button on UI thread to ask android read what desktop have written, android will begin access to MySQL server.
In server side, 2 php files ( update database and read database php files) is created and located at htdocs. After android will success to access into server, then android will begin searching the php files requested (either update or read php files) through HTTP protocol.
Request ask for read database php file to work. When read database php file is executed, php file will begin it’s work by log in to database and retrieve the data requested that what desktop have written into database. After, php get the data it wants from database, it will pass it again to android and android get the data and put it on UI thread to show user what data have retrieved from database.
If the desktop ask for what android have written, it (desktop) will do exactly same things as what android did. desktop will going 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 have written into database. After database adapter get what their want, 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 contains three java source code. (JsonParser, JsonPost and MainThread)
  • JsonParser.java contains HttpGet method. There is no input data to url, only retrieve data from php file.
  • JsonPost.java contains HttpPost method. This method allow data post into php file.
  • MainThread.java is a UI thread work that called the button or textView method allow user talk with machine.

  • mysqlDesktop is an java Swing project. Inside this project contains three java source code and one external jar that is DatabaseAdapter.java, jConnector.java and MainFrame.java and mysql-java Connector.
  • jConnector.java contains the source code that allow java project connect to MySQL database.
  • DatabaseAdapter.java used to make database work getting easier to carry out.
  • MainFrame.java is a source code allow user to talk with device through window form