Android (Java) Simple Send and Receive with Server - Fast Setup Challenge

Android (Java) Simple Send and receive with Server - Fast Setup Challenge

private void sendData(ProfileVO pvo) {

Log.i(getClass().getSimpleName(), "send task - start");

HttpParams p=new BasicHttpParams();
p.setParameter("name", pvo.getName());

//Instantiate an HttpClient
HttpClient client = new DefaultHttpClient(p);

//Instantiate a GET HTTP method
try {
HttpResponse response=client.execute(new HttpGet("http://www.itortv.com/android/sendName.php"));
InputStream is=response.getEntity().getContent();
//You can convert inputstream to a string with: http://senior.ceng.metu.edu.tr/2009/praeda/2009/01/11/a-simple-restful-client-at-android/
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Log.i(getClass().getSimpleName(), "send task - end");
}

I am entering birthdate inside edittext using datepicker. How to catch this?

Get reference to your EditText and use getText() method to get the text and
on How to put into web server,

This can be one of the way.
Check this,

Android (Java) Simple Send and receive with Server - Fast Setup Challenge

How to get data from a database and update it in app in android?

Yes. You need to create one web service and deploy it on your server which query the database and return the response in JSON/XML format and then parse that response and update your app's data. That's the straight simple way.


As you said you need to do this daily, you can think of creating a Service for the task and might be you can use AlarmManager too.

Android - Want to transfer data from SQLITE db to Web Server

You can use web services to send data to server.

The approach you may need to choose will be, have a service hosted on your server (could be written in any programming language) which retrieves/posts data from database and sends data in either JSON/XML format ( I did JSon format) to app. In your app use HTTPClient to get/post data to service hosted on your server. Parse the data using Android in built JSon API.

How to consume web service in android refer following links :

Android (Java) Simple Send and receive with Server - Fast Setup Challenge

Send data from android to webserver

Send data from android to server via JSON

Android Utility to send sqlite db to server



Related Topics



Leave a reply



Submit