java - Click in a button and save in database some values of the phone by http call in Android -
i trying save edittext's in database url in http. store values in url of http. can give advice of code of how it? have in main activity.
edittext ean,description,bb_date,qty; button save; i want make url of this: "http://company.author.com/requests.php?action=sku&getean=9999999999999&description=...&bb_date=20151405&qty=100"
try this:
save.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { httpclient httpclient = new defaulthttpclient(); stringbuilder url_select = new stringbuilder(); url_select.append("http://company.author.com/requests.php?action="); url_select.append("sku"); url_select.append("&getean="); url_select.append(ean.gettext().tostring()); url_select.append("&description="); url_select.append(description.gettext().tostring()); url_select.append("&bb_date="); url_select.append(bb_date.gettext().tostring()); url_select.append("&qty="); url_select.append(qty.gettext().tostring()); string url = url_select.tostring().replace(" ","%20"); httppost httppost = new httppost(url); arraylist<namevaluepair> param = new arraylist<namevaluepair>(); try { httppost.setentity(new urlencodedformentity(param)); httpresponse httpresponse = httpclient.execute(httppost); httpentity httpentity = httpresponse.getentity(); //read content = httpentity.getcontent(); } catch (exception e) { log.e("log_tag", "error in http connection " + e.tostring()); } } });
Comments
Post a Comment