iReminiscence
Member
- Joined
- Nov 29, 2009
- Messages
- 249
- Reaction score
- 0
Hello,
Im able to delete all the data from the content provider but
Just want to ask that if i want to delete only one data, how do i go about doing this?
what should be my code to access it was
getContentResolver().delete(addresses, ???? , ???);
or
getContentResolver().delete(addresses.buildUpon()
.appendPath(String.valueOf(???)).build(), null, null);
??

Im able to delete all the data from the content provider but
Just want to ask that if i want to delete only one data, how do i go about doing this?
what should be my code to access it was
getContentResolver().delete(addresses, ???? , ???);
or
getContentResolver().delete(addresses.buildUpon()
.appendPath(String.valueOf(???)).build(), null, null);
??


public int delete(Uri uri, String selection, String[] selectionArgs) {
int count = 0;
System.out.println();
switch (uriMatcher.match(uri)) {
case ADDRESSES:
count = db.delete(ADDRESSES_TABLE_NAME, selection, selectionArgs);
break;
case ADDRESS_ID:
String id = uri.getLastPathSegment();
count = db.delete(ADDRESSES_TABLE_NAME, _ID
+ " = "
+ id
+ (!TextUtils.isEmpty(selection) ? " AND (" + selection
+ ')' : ""), selectionArgs);
break;
default:
throw new IllegalArgumentException("Unknown URI " + uri);
}
getContext().getContentResolver().notifyChange(uri, null);
return count;
}
int count = 0;
System.out.println();
switch (uriMatcher.match(uri)) {
case ADDRESSES:
count = db.delete(ADDRESSES_TABLE_NAME, selection, selectionArgs);
break;
case ADDRESS_ID:
String id = uri.getLastPathSegment();
count = db.delete(ADDRESSES_TABLE_NAME, _ID
+ " = "
+ id
+ (!TextUtils.isEmpty(selection) ? " AND (" + selection
+ ')' : ""), selectionArgs);
break;
default:
throw new IllegalArgumentException("Unknown URI " + uri);
}
getContext().getContentResolver().notifyChange(uri, null);
return count;
}
