title: Database Values not updating in Android
body: <p>I am trying to update the database on server but there seems to be some problem with the code. Code goes to the <code>catch</code> block and Toast with message of null is displayed. </p>
  
  <pre><code>public class Test extends AppCompatActivity {
  
      static String inputLine, data = "";
      HttpURLConnection conn = null;
  
      String q = "update data set room='ANKUSH' where id='5'";
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_test);
  
          try {
              URL url = new URL("http://takeyourtime.16mb.com/postdb.php");
              String agent = "Applet";
              String q2 = "insert into user(name,username,password,email) values('AHA','xxxAA','xxxA','xSDxx')";
              String query = "query=" + q2;
              String type = "application/x-www-form-urlencoded";
              conn = (HttpURLConnection) url.openConnection();
              conn.setDoInput(true);
              conn.setDoOutput(true);
              conn.setRequestMethod("POST");
              conn.setRequestProperty("User-Agent", agent);
              conn.setRequestProperty("Content-Type", type);
              conn.setRequestProperty("Content-Length", "" + query.length());
  
              OutputStream out = conn.getOutputStream();
              out.write(query.getBytes());
              BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
              while ((inputLine = in.readLine()) != null) {
                  data = data + inputLine + "\n";
              }
              //data = StringParser.StringPars(data);
              in.close();
              int rc = conn.getResponseCode();
              System.out.print("Response Code = " + rc + "\n");
              String rm = conn.getResponseMessage();
              System.out.print("Response Message = " + rm + "\n");
              Toast.makeText(this, "Response Code = " + rc + "\n", Toast.LENGTH_SHORT).show();
          } catch (Exception e) {
              e.printStackTrace();
              Toast.makeText(this, e.getMessage() + "\n" + e.getCause(), Toast.LENGTH_SHORT).show();
          } finally {
              conn.disconnect();
          }
      }
  }
  </code></pre>