Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid app connect to mysql database
    primarykey
    data
    text
    <p>i am try to connect my android app with mysql database but http is not responding or it may not work. please suggest me what to do?</p> <p>HTTP Method Not Allowed: <a href="http://developer.android.com/tools/extras/support-library.html/content.xml" rel="nofollow">http://developer.android.com/tools/extras/support-library.html/content.xml</a> HttpClient connection error response code 405.</p> <p>public class MainActivity extends Activity {</p> <pre><code> TextView resultview; private InputStream is; @SuppressLint("NewApi") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); resultview=(TextView) findViewById(R.id.resultview); } public void getData() { String result = ""; //the year data to send //http post try { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("http://10.0.2.2/echo/db.php"); HttpResponse response = httpclient.execute(httppost); HttpEntity entity = response.getEntity(); is = entity.getContent(); Log.e("log_tag", "connection success "); Toast.makeText(getApplicationContext(), "pass", Toast.LENGTH_SHORT).show(); } catch(Exception e) { Log.e("log_tag", "Error in http connection "+e.toString()); Toast.makeText(getApplicationContext(), "Connection fail", Toast.LENGTH_SHORT).show(); } //convert response to string try { BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8); StringBuilder sb = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + "\n"); Toast.makeText(getApplicationContext(), "Input Reading pass", Toast.LENGTH_SHORT).show(); } is.close(); result=sb.toString(); } catch(Exception e) { Log.e("log_tag", "Error converting result "+e.toString()); Toast.makeText(getApplicationContext(), " Input reading fail", Toast.LENGTH_SHORT).show(); } //parse json data try { JSONArray jArray = new JSONArray(result); for(int i=0;i&lt;jArray.length();i++){ JSONObject json_data = jArray.getJSONObject(i); Log.i("log_tag","id: "+json_data.getInt("id")+ ", Name: "+json_data.getString("name")+ ", Address: "+json_data.getInt("address")+ ", Contact: "+json_data.getInt("contact") ); Toast.makeText(getApplicationContext(), "JsonArray pass", Toast.LENGTH_SHORT).show(); } } catch(JSONException e) { Log.e("log_tag", "Error parsing data "+e.toString()); Toast.makeText(getApplicationContext(), "JsonArray fail", Toast.LENGTH_SHORT).show(); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    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