Search code examples
phpandroidandroid-internet

Connect to MySQL database using volley or other library


In many websites tutorials connection to a database of MySQL in Android uses httpclient class and name pair values ,which is deprecated by Google .So how to do it using volley or any other library.


Solution

  • If your posting is RESTful, you can probably consume the service with Spring for Android: http://projects.spring.io/spring-android/

    Keep in ind although that this is build for Spring web services. You might need to tweak it to support your service and method. Also and generic Java HTTP client API can be used to post data including Apache Commons:

    Sending POST data in Android

    String myPostURL = "http://yoursite.com/yourPost";
    RestTemplate template = new RestTemplate();
    Object o res = postForObject(myPostURL, anObjectWithData, Object.class);
    

    This will (if I am correct) POST form data to your url, and return an Object containing the response. You may or may not have to make sure that your Android data is posted as html form da.ta