php - Android: Sending data to be stored in MySQL -


solved: missing view parameter postdata(), changed reflect this.

i sending gps data server stored in mysql database using php.

this inside java file:

arraylist<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(2);  public void postdata(view v) {     namevaluepairs.add(new basicnamevaluepair("lat","19.80"));     namevaluepairs.add(new basicnamevaluepair("lon","13.22"));      //http post     try{         httpclient httpclient = new defaulthttpclient();         httppost httppost = new               httppost("http://www.xxxxxxxx.com/test.php");         httppost.setentity(new urlencodedformentity(namevaluepairs));         httpresponse response = httpclient.execute(httppost);         httpentity entity = response.getentity();         inputstream = entity.getcontent();         log.i("postdata", response.getstatusline().tostring());     }      catch(exception e)     {         log.e("log_tag", "error in http connection "+e.tostring());     }            } 

and php:

<?php include 'connect.php'; //connect  //retrieve data $lat = $_post['lat']; $lon = $_post['lon'];  $sql = "insert coords (lat, lon) values('$lat', '$lon')";  if (!mysql_query($sql, $sqlcon)) {     die('error: ' . mysql_error()); } else {     //echo "1 record added"; }  include 'closeconnection.php'; ?> 

stacktrace: project - heat [android application]

 02-06 00:37:14.265: error/androidruntime(1607): fatal exception: main  02-06 00:37:14.265: error/androidruntime(1607): java.lang.illegalstateexception:         not find method **postdata(view)** in activity class com.nathanhunston.heat.main     onclick handler on view class android.widget.button id 'droplocbtn' 

the first line of stack trace tells doing wrong:

02-06 00:37:14.265: error/androidruntime(1607): fatal exception: main 02-06 00:37:14.265: error/androidruntime(1607): java.lang.illegalstateexception: not find method postdata(view) in activity class com.nathanhunston.heat.main onclick handler on view class android.widget.button id 'droplocbtn' 

that because not have view parameter in postdata() method declaration.


Comments