Code example for ContentResolver

Methods: delete

0
	 * @return The resulting cursor. 
	 */ 
	private Cursor runQuery(ContentResolver resolver)
	{ 
		QueryTask query = MediaUtils.buildPlaylistQuery(mPlaylistId, PROJECTION, null);
		return query.runQuery(resolver);
	} 
 
	@Override 
	public void move(int from, int to)
	{ 
		if (from == to)
			// easy mode 
			return; 
 
		int count = getCount();
		if (to >= count || from >= count)
			// this can happen when the adapter changes during the drag 
			return; 
 
		// The Android API contains a method to move a playlist item, however, 
		// it has only been available since Froyo and doesn't seem to work 
		// after a song has been removed from the playlist (I think?). 
 
		ContentResolver resolver = mContext.getContentResolver();
		Uri uri = MediaStore.Audio.Playlists.Members.getContentUri("external", mPlaylistId);
		Cursor cursor = getCursor();
 
		int start = Math.min(from, to);
		int end = Math.max(from, to);
 
		long order;
		if (start == 0) {
			order = 0;
		} else { 
			cursor.moveToPosition(start - 1);
			order = cursor.getLong(4) + 1;
		} 
 
		cursor.moveToPosition(end);
		long endOrder = cursor.getLong(4);
 
		// clear the rows we are replacing 
		String[] args = new String[] { Long.toString(order), Long.toString(endOrder) };
		resolver.delete(uri, "play_order >= ? AND play_order <= ?", args);
 
		// create the new rows 
		ContentValues[] values = new ContentValues[end - start + 1];
		for (int i = start, j = 0; i <= end; ++i, ++j, ++order) {
			cursor.moveToPosition(i == to ? from : i > to ? i - 1 : i + 1);
			ContentValues value = new ContentValues(2);
			value.put(MediaStore.Audio.Playlists.Members.PLAY_ORDER, Long.valueOf(order));
			value.put(MediaStore.Audio.Playlists.Members.AUDIO_ID, cursor.getLong(3));
			values[j] = value;
		} 
 
		// insert the new rows 
		resolver.bulkInsert(uri, values);
 
		changeCursor(runQuery(resolver));
	} 
 
	@Override 
	public void remove(int position)
	{ 
		ContentResolver resolver = mContext.getContentResolver();
		Uri uri = MediaStore.Audio.Playlists.Members.getContentUri("external", mPlaylistId);
		resolver.delete(ContentUris.withAppendedId(uri, getItemId(position)), null, null);
		changeCursor(runQuery(resolver));
	} 
} 
Connect your IDE to all the code out there  Get Codota for Java