Reputation: 787
How can we delete all rows from an Android Table using the ContentResolver
?
I have tried:
context.getContentResolver().delete(Abcd.CONTENT_URI, null, null);
context.getContentResolver().delete(Abcd.CONTENT_URI, "1", null);
And I know my uri is correct as when I give a condition as :
context.getContentResolver().delete(Channel.CONTENT_URI, "name = ?", "abcd");
the code works.
What is the correct way to delete all?
Right now I am using a hack: context.getContentResolver().delete(Channel.CONTENT_URI, "name != ?", "");
as name can never be empty.
But I would like to know the best way possible.
Upvotes: 5
Views: 3409
Reputation: 40236
Please use,
getActivity().getContentResolver().delete(CONTENT_URI, null, null);
Upvotes: 2