Best way to transmit sqlite data to a web server from an Android Unit?
The title almost says it all.
I'm building an Android App to collect data on sites. The data is stored in a sqlite database on the unit.
I'd like to transmit them to a web server over wifi. The data is to be stored in sql form and analysed on the web server, then graphed on a web page.
I though about making a csv and send it to a php page that would parse it and write it to the server sql database. I saw alson json, but must read more about it.
What are the best opt开发者_如何学Cions to have the data transfered with integrity ?
Thanks a lot
I would recommend using JSON for a couple reasons:
- It is human readable.
- There are nice libraries for JSON-Object Mapping, such as Jackson or GSON.
- There are
JSONObject
/JSONArray
classes that are a part of Android that are easy to use.
As an additional option you can use Google's protocol buffers. With protobuf you have to include an additional library and write your data in a specific message format, but you gain an automatically generated library with getter/setter methods and the data is sent in binary form. All you have to do on either end is send/receive the number of bytes of the message and then write/read the message itself; the library takes care of populating all of your instance variables.
Of course this depends on what language you are using on the server, as you have to use a protobuf library there as well; but it would appear that there are many different language bindings, including for PHP.
精彩评论