Insert String and image to mysql server by android app -
this link http://amancomputers.com/mm/pma-front/services/reply.php
link content->insert incomming_message(content,date,image) values('',now(),''){"login":1}
i want send text , image in content , image respectively using android app. have tried code
@override protected string doinbackground(string... params) { //for(int i=0;i<5;i++) { httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost("http://amancomputers.com/mm/pma-front/services/reply.php"); seek { // add together info list<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(2); namevaluepairs.add(new basicnamevaluepair("content","name abcd")); namevaluepairs.add(new basicnamevaluepair("image", "anddev cool!")); httppost.setentity(new urlencodedformentity(namevaluepairs)); // execute http post request httpresponse response = httpclient.execute(httppost); } grab (clientprotocolexception e) { // todo auto-generated grab block } grab (ioexception e) { // todo auto-generated grab block } grab (jsonexception e) { // todo auto-generated grab block e.printstacktrace(); } homecoming "success"; }
i have tried code. problem new id created unable send text or image on server. , exception in logcat:
unable convert java.lang.string jsonobjects
you creating jsonobject
string
("12345") not valid json, seek valid json string, e.g.
jsonobject jsonobject = new jsonobject("{\"whatever\":\"12345\"}");
or empty object
jsonobject jsonobject = new jsonobject();
android
No comments:
Post a Comment