I am working on android. i am sending username and password using HttpPost and getting userid.
This is my code for my operation:
HttpClient hc = new DefaultHttpClient();
HttpPost post = new HttpPost("http://192.168.1.214/sample/dologin.php id="+strUID+ "&password="+strPass);
HttpResponse rp = hc.execute(post);
if (rp.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
String userID = EntityUtils.toString(rp.getEntity());
Log.v("Login response", "" + userID);
}
This is my output in DDMS
Login response(686): ([{"id":"5"}]);
But I need 5 as a result. So I can use this result in my next operations. Please tell me what should I do to extract 5 from the string ([{“id”:”5″}]);
Thank you in advance.
You can use JSON below is simple code..
Now you can use id variable..