Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to send data (filled in a application form in my android app) to website( my local host)?
    primarykey
    data
    text
    <p>I am a new android developer . I am building an app , in which a registration form is filled and its contents data is to be stored on the local host of mine . I have made the form but i don't know how to code for sending the data to local host. help me code from the basic so that WHEN A SEND BUTTON IS CLICKED , THE DATA FILLED IN THE FORM GETS STORED ON THE LOCAL HOST.</p> <p>this is my code..................................</p> <pre><code>protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_activity_server); send1 = (Button)findViewById(R.id.Send); send1.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub testInput ti=new testInput(); //Create the intent ti.postData("Sent Data"); TextView num1View = (TextView) findViewById(R.id.T5); num1View.setText("your data is stored"); //Create the intent } }); } public void postData(String toPost) { // Create a new HttpClient and Post Header HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("my local host name"); //This is the data to send String name = toPost; String number= toPost; String email =toPost; String suggestion= toPost;//any data to send try { // Add your data List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(1); nameValuePairs.add(new BasicNameValuePair("action", name)); nameValuePairs.add(new BasicNameValuePair("action", number)); nameValuePairs.add(new BasicNameValuePair("action", email)); nameValuePairs.add(new BasicNameValuePair("action", suggestion)); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); // Execute HTTP Post Request ResponseHandler&lt;String&gt; responseHandler = new BasicResponseHandler(); String response = httpclient.execute(httppost, responseHandler); //This is the response from a php application String reverseString = response; Toast.makeText(this, "response" + reverseString, Toast.LENGTH_LONG).show(); } catch (ClientProtocolException e) { Toast.makeText(this, "CPE response " + e.toString(), Toast.LENGTH_LONG).show(); // TODO Auto-generated catch block } catch (IOException e) { Toast.makeText(this, "IOE response " + e.toString(), Toast.LENGTH_LONG).show(); // TODO Auto-generated catch block } }//end postData() </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload