title: Delete an item using an OnItemLongClickListener
body: <p>I want to delete an item from the ListView using an OnItemLongClickListener.<br>
  This is my code to make an AlertDialog appear when I OnLongClick an item.<br>
  I also need to now what code to use when I delete an Item  </p>
  
  <pre><code>public class DeleteItem extends Activity {
  
   ListView list;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
          list = (ListView) findViewById(R.id.listView);
          list.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
  
              @Override
              public boolean onItemLongClick(AdapterView&lt;?&gt; arg0, View arg1,
                      int arg2, long arg3) {
                  AlertDialog.Builder alert = new AlertDialog.Builder(DeleteItem.this);
                  alert.setMessage("Are you sure you want to delete this?");
                  alert.setCancelable(false);
                  alert.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
  
                      @Override
                      public void onClick(DialogInterface dialog, int which) {
                          //Here I need the delete code
                      }
                  });
                  alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
  
                      @Override
                      public void onClick(DialogInterface dialog, int which) {
                          dialog.cancel();
  
                      }
                  });
  
  
                  return false;
  
              }
          });
  
         }
      }
  </code></pre>