title: On long click delete item
body: <p>I have ListView which is saving all data to database. For adding i have simple button and textBox which adds to database, and show to listView. Now i want thath on long item click (hold on item) will delete the selected item from list. How is possible to do thath (actualy what method to call for long click).</p>
  
  <p>Here is current code:</p>
  
  <pre><code>import java.util.List;
  import java.util.Random;
  
  import android.app.ListActivity;
  import android.os.Bundle;
  import android.text.Editable;
  import android.view.View;
  import android.widget.ArrayAdapter;
  import android.widget.EditText;
  import android.widget.ListView;
  
  public class Announce extends ListActivity{
      private CommentsDataSource datasource;
      EditText edit;
      ListView list;
  
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.announce);
  
          datasource = new CommentsDataSource(this);
          datasource.open();
  
          List&lt;Comment&gt; values = datasource.getAllComments();
  
          ArrayAdapter&lt;Comment&gt; adapter = new ArrayAdapter&lt;Comment&gt;(this,
                  android.R.layout.simple_list_item_1, values);
          setListAdapter(adapter);
      }
  
  
      public void onClick(View view) {
          @SuppressWarnings("unchecked")
          ArrayAdapter&lt;Comment&gt; adapter = (ArrayAdapter&lt;Comment&gt;) getListAdapter();
          Comment comment = null;
          switch (view.getId()) {
          case R.id.add:
              edit = (EditText)findViewById(R.id.editTxt);
              Editable txt=(Editable)edit.getText();
              String input = txt.toString();          
              comment = datasource.createComment(input);
              adapter.add(comment);
              break;  
          }
          adapter.notifyDataSetChanged();
      }
  
  
  
      @Override
      protected void onResume() {
          datasource.open();
          super.onResume();
      }
  
      @Override
      protected void onPause() {
          datasource.close();
          super.onPause();
      }
  
  }
  </code></pre>