to store data in mysql from android
<p>Here i have attached my code this doesn't show me any sort of error.. But data is not being inserted into mysql table. can anyone help me out. I have made my ddms connection correctly. But still its not working.</p>

<p>my java code:</p>

<pre><code>  public class MainActivity extends Activity {
    Button b1;
    EditText et1, et2;
    String name, place;
    InputStream is;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        b1 = (Button) findViewById(R.id.button1);
        et1 = (EditText) findViewById(R.id.editText1);
        et2 = (EditText) findViewById(R.id.editText2);
        name = et1.getText().toString();
        place = et2.getText().toString();

        b1.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub

                // Building Parameters
                ArrayList&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;();
                params.add(new BasicNameValuePair("name", name));
                params.add(new BasicNameValuePair("place", place));

                try {
                    HttpClient httpclient = new DefaultHttpClient();
                    HttpPost httppost = new HttpPost(
                            "http://10.0.2.2/insert.php");
                    httppost.setEntity(new UrlEncodedFormEntity(params));
                    HttpResponse response = httpclient.execute(httppost);
                    HttpEntity entity = response.getEntity();
                    is = entity.getContent();

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

        });
    }
</code></pre>

<p>and my php is here:</p>

<pre><code> &lt;?php
$con=mysqli_connect("localhost","root","","sample");

if(isset($_POST['name'],$_POST['place']))
{
$name=$_POST['name'];
$place=$_POST['place'];
$sql="INSERT INTO sampletable (name,place) VALUES('$name','$place')";

mysqli_query($con,$sql);
}
echo "1 record added";

mysqli_close($con);
?&gt;
</code></pre>
