Playlists.Members has a static method moveItem() which should take care of updating the play orders in the playlist. If you know the size of the playlist, try first moving the item to the end of the playlist, then delete the item.
private boolean deleteFromPlayList(long playlistId, int position, int playlistSize) {
ContentResolver cr = getContentResolver(); // or pass it in method args
// I'm assuming play order starts at 1, but if it starts at 0,
// then change this check accordingly
if (position != playlistSize) {
// this will return true on success, in case you want to check that it moved
Playlists.Members.moveItem(cr, playlistId, position, playlistSize);
}
return cr.delete(...) > 0;
}
One thing to note is that moveItem() will result in a Uri notification when it moves the item, so if you have a Loader or something listening for that, it will get triggered. This may or may not be an issue. You might be able to avoid this by using applyBatch(), in which case you'll have to build the move operation yourself. Based on the source code around line 1653, it should be an update operation.
ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(2);
Uri moveUri = Playlists.Members.getContentUri("external", playlistId)
.buildUpon()
.appendPath(Integer.toString(position))
.appendQueryParameter("move", "true")
.build();
ops.add(ContentProviderOperation.newUpdate(moveUri)
.withValue(Playlists.Members.PLAY_ORDER, playlistSize)
.build());
Uri deleteUri = Playlists.Members.getContentUri("external", playlistId)
.buildUpon()
.appendPath(Long.toString(playlistMemberId))
.build();
ops.add(ContentProviderOperation.newDelete(deleteUri).build());
contentResolver.applyBatch(MediaStore.AUTHORITY, ops);