title: Get spinner selected item on database and delete
body: <p>This is my code for the <strong>spinner</strong> which is getting <code>data</code> from online database. The code is fine. I can't find any <strong>spinner</strong> that is getting a data from online database and having a <code>delete</code>. There are some, but not helpful for me because it only shows 1 <code>data</code> and hardly to understand. Can someone help me how to create a <code>delete</code> statement?</p>
  
  <p>PS* I'm using an <strong><em>activity</em></strong> not a <em>dialog</em>.</p>
  
  <p>PS** I'm new in <strong>Java</strong> having a hard time to understand</p>
  
  <p>This line gets the data from the database and setting the get data to string.</p>
  
  <pre><code> private void getData() {
      StringRequest stringRequest = new StringRequest(Config.DATA_URL, new Response.Listener&lt;String&gt;() {
          @Override
          public void onResponse(String response) {
              JSONObject j = null;
              try {
                  j = new JSONObject(response);
                  result = j.getJSONArray(Config.JSON_ARRAY);
                  getDate(result);
              } catch (JSONException e) {
                  e.printStackTrace();
              }
          }
      },
              new Response.ErrorListener() {
                  @Override
                  public void onErrorResponse(VolleyError error) {
  
                  }
              });
      RequestQueue requestQueue = Volley.newRequestQueue(this);
      requestQueue.add(stringRequest);
  }
  
  private void getDate(JSONArray j) {
      for (int i = 0; i &lt; j.length(); i++) {
          try {
              JSONObject json = j.getJSONObject(i);
              albay.add(json.getString(Config.TAG_DATE));
          } catch (JSONException e) {
              e.printStackTrace();
          }
      }
      spinner.setAdapter(new ArrayAdapter&lt;String&gt;(UpdateData.this, android.R.layout.simple_spinner_dropdown_item, albay));
  }
  
  private String getlocation1(int position) {
      String location1 = "";
      try {
          //Getting object of given index
          JSONObject json = result.getJSONObject(position);
          //Fetching name from that object
          location1 = json.getString(Config.TAG_LOCATION1);
      } catch (JSONException e) {
          e.printStackTrace();
      }
      return location1;
  }
  
  private String getlocation2(int position) {
      String location2 = "";
      try {
          JSONObject json = result.getJSONObject(position);
          location2 = json.getString(Config.TAG_LOCATION2);
      } catch (JSONException e) {
          e.printStackTrace();
      }
      return location2;
  }
  </code></pre>
  
  <p>This is where the get data goes to the <strong>textview</strong></p>
  
  <pre><code>public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int position, long id) {
      //Setting the values to textviews for a selected item
      textViewLocation1.setText(getlocation1(position));
      textViewLocation2.setText(getlocation2(position));
  </code></pre>
  
  <p>This my delete code in other java class. I don't know how to call it from <code>onclicklistenter</code>. Is this code works?</p>
  
  <pre><code> public boolean delete(int position) {
      try {
          albay.remove(position);
          return true;
      } catch (Exception e) {
          e.printStackTrace();
          return false;
      }
  }
  </code></pre>