-
Notifications
You must be signed in to change notification settings - Fork 717
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.15 Implement ContentProvider delete() method
- Loading branch information
Beginning Android
committed
Aug 23, 2016
1 parent
a1bcc0c
commit 81fe10a
Showing
1 changed file
with
20 additions
and
5 deletions.
There are no files selected for viewing
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
81fe10a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i still confuse about this statement :
= new String[] { String.valueOf(ContentUris.parseId(uri)) };
Can you please explain to me what happen inside. Thx
81fe10a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that statement we extract the Id from ContentUris using
parseId
method an then store it in SelectionArgs.Lets say the
uri
is something like this:content://com.example.android.pets/pets/5
We call
String.valueOf(ContentUris.parseId(uri))
and then we store 5 in our selectionArgs String Array.
Selection: “_ID=?”
SelectionArgs: { “5” }
So the query will be something like
DELETE FROM pets WHERE _ID=5;
81fe10a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice work
81fe10a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice piece of code but when I run it on an emulator or phone, it does not delete anything yet....
Anyone any suggestions?
81fe10a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi ID2GO, the app bar menus do not yet have an instruction to delete. Right now it says: // Do nothing for now
81fe10a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah tinapleez, I realised that later on down the road. But thanx!
81fe10a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool. I figured that, since your post is dated over a week ago. I thought I'd put the comment up for future confused students, because I also was thrown a little bit by the abruptness at the end of the lesson.