From e3d05fcf396fd0e48a0741df4ddb77533fe934b3 Mon Sep 17 00:00:00 2001 From: Marco Nelissen Date: Wed, 9 Dec 2009 16:01:46 -0800 Subject: [PATCH] cherry-pick of am 7cd40294: Merge change I2cb78a66 into eclair-mr2 Merge commit '7cd4029473431c56100e52f631b9733829dc3171' into eclair-mr2-plus-aosp * commit '7cd4029473431c56100e52f631b9733829dc3171': Add convenience function to MediaStore to move a playlist item --- core/java/android/provider/MediaStore.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/core/java/android/provider/MediaStore.java b/core/java/android/provider/MediaStore.java index a796fe9944be9..ae53dbe2d2cb8 100644 --- a/core/java/android/provider/MediaStore.java +++ b/core/java/android/provider/MediaStore.java @@ -1251,6 +1251,28 @@ public final class MediaStore { + "/audio/playlists/" + playlistId + "/members"); } + /** + * Convenience method to move a playlist item to a new location + * @param res The content resolver to use + * @param playlistId The numeric id of the playlist + * @param from The position of the item to move + * @param to The position to move the item to + * @return true on success + * @hide + */ + public static final boolean moveItem(ContentResolver res, + long playlistId, int from, int to) { + Uri uri = MediaStore.Audio.Playlists.Members.getContentUri("external", + playlistId) + .buildUpon() + .appendEncodedPath(String.valueOf(from)) + .appendQueryParameter("move", "true") + .build(); + ContentValues values = new ContentValues(); + values.put(MediaStore.Audio.Playlists.Members.PLAY_ORDER, to); + return res.update(uri, values, null, null) != 0; + } + /** * The ID within the playlist. */