Last active
November 13, 2019 20:46
-
-
Save udacityandroid/266e8875e63b25d219f153ba72613ea9 to your computer and use it in GitHub Desktop.
Pets app - Replace delete() method in PetProvider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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); | |
} | |
} |
Yeah... I was like, "Ok... paste the gist.... ok.... uhm.... looks complete to me. What did I miss???? Did I just cheat?!?! Oh.... they gave us the answer." Well, crap, so much for trying on my own. LOL!
Your Task: Implement delete() method . . . . . . by cut 'n' paste, go on you can do it, I have faith in you 👍
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@Nikoloutsos I think it would be selection = name + "=? AND " + gender + "=?";
selectArgs[] = {"totti", "male"}