Send data from android to server via JSON

前端 未结 4 1202
陌清茗
陌清茗 2020-11-30 08:35
  1. I have MySQL database server
  2. I need to update and retrieve data to/from MySQL server via JSON

So, I want to know how to do that, and I pretty

4条回答
  •  醉酒成梦
    2020-11-30 08:54

    Since an Android application cannot connect directly to a MySQL server you need to write a kind of a "bridge".

    UPDATE: @see Femi's comment

    Well, technically speaking, It could: http://developer.android.com/reference/javax/sql/package-summary.html

    But for security reasons a bridge is a mandatory choice IMHO.

    One one the most popular approach is to use the http protocol for sending and reading data.

    Your city.php will contain the logic for connect and querying the database:

    
    

    The Android app will connect trough your server and will parse the json output.

    So yes, you need to write the server-side part and client side part (Android)

    A really useful video: http://www.google.com/events/io/2010/sessions/developing-RESTful-android-apps.html

    Code sample with PHP as bridge and Android via http protocol:

    http://www.helloandroid.com/tutorials/connecting-mysql-database

提交回复
热议问题