Skip to content

Instantly share code, notes, and snippets.

@udacityandroid
Last active November 13, 2019 20:46
Show Gist options
  • Save udacityandroid/266e8875e63b25d219f153ba72613ea9 to your computer and use it in GitHub Desktop.
Save udacityandroid/266e8875e63b25d219f153ba72613ea9 to your computer and use it in GitHub Desktop.

Revisions

  1. udacityandroid revised this gist Oct 21, 2016. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions Excerpt from PetProvider.java
    Original file line number Diff line number Diff line change
    @@ -16,3 +16,4 @@ public int delete(Uri uri, String selection, String[] selectionArgs) {
    default:
    throw new IllegalArgumentException("Deletion is not supported for " + uri);
    }
    }
  2. udacityandroid created this gist Sep 7, 2016.
    18 changes: 18 additions & 0 deletions Excerpt from PetProvider.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    @Override
    public int delete(Uri uri, String selection, String[] selectionArgs) {
    // Get writeable database
    SQLiteDatabase database = mDbHelper.getWritableDatabase();

    final int match = sUriMatcher.match(uri);
    switch (match) {
    case PETS:
    // Delete all rows that match the selection and selection args
    return database.delete(PetEntry.TABLE_NAME, selection, selectionArgs);
    case PET_ID:
    // Delete a single row given by the ID in the URI
    selection = PetEntry._ID + "=?";
    selectionArgs = new String[] { String.valueOf(ContentUris.parseId(uri)) };
    return database.delete(PetEntry.TABLE_NAME, selection, selectionArgs);
    default:
    throw new IllegalArgumentException("Deletion is not supported for " + uri);
    }