Ankit Aggarwal
Ankit Aggarwal

Reputation: 787

Delete ALL rows from TABLE using ContentResolver

How can we delete all rows from an Android Table using the ContentResolver?

I have tried:

  1. context.getContentResolver().delete(Abcd.CONTENT_URI, null, null);

  2. 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

Answers (1)

Sazzad Hissain Khan
Sazzad Hissain Khan

Reputation: 40236

Please use,

getActivity().getContentResolver().delete(CONTENT_URI, null, null);

Upvotes: 2

Related Questions