title: Calling delete method in custom content provider
body: <p>I am learning Android and I am stuck on an issue involving calling a custom content provider. I have been using an example in an instructional book and although it describes how to create the custom provider there is no clear example how to call the specific methods in it. I am specifically looking into how to delete a single record from the custom content provider.</p>
  
  <p>Here is the code for the custom content provider (<code>EarthquakeProvider.java</code>):</p>
  
  <pre><code>@Override
  
  
  public int delete(Uri uri, String where, String[] whereArgs) {
  int count;
  
  switch (uriMatcher.match(uri)) {
    case QUAKES:
      count = earthquakeDB.delete(EARTHQUAKE_TABLE, where, whereArgs);
      break;
  
    case QUAKE_ID:
      String segment = uri.getPathSegments().get(1);
      count = earthquakeDB.delete(EARTHQUAKE_TABLE, KEY_ID + "="
                                  + segment
                                  + (!TextUtils.isEmpty(where) ? " AND (" 
                                  + where + ')' : ""), whereArgs);
      break;
  
    default: throw new IllegalArgumentException("Unsupported URI: " + uri);
  }
  
  getContext().getContentResolver().notifyChange(uri, null);
  return count;
  
  
   }
  </code></pre>
  
  <p>I am trying to call the delete method from the main activity to delete a single entry, not the entire database. I want to use about an <code>OnLongClickListener</code> for the selected record that is displayed in a array list view in the main activity.</p>
  
  <p>This is what I have come up with I have so far in my main activity for this method:</p>
  
  <pre><code>earthquakeListView.setOnItemLongClickListener(new OnItemLongClickListener() {
  
      @Override
      public boolean onItemLongClick(AdapterView _av, View _v, int _index,
              long arg3) {
          ContentResolver cr = getContentResolver();
          cr.delete(earthquakeProvider.CONTENT_URI, null, null); 
  
          return false;
      }
  </code></pre>
  
  <p>I know the above code doesn't work, but this is as close as I could get with my current understanding.</p>
  
  <p>Any help on this would be very much appreciated.</p>