Android mini album icon

I got some cover for the album (I have an identifier and a bitmap), and now I want to set it to MediaStore.

I tried a bunch of things:

private static final Uri ARTWORK_URI = Uri.parse("content://media/external/audio/albumart"); public static void writeArtwork(Context context, Bitmap bmp, int albumId) { ContentResolver res = context.getContentResolver(); Uri uri = ContentUris.withAppendedId(ARTWORK_URI, albumId); LogUtil.i(TAG, "uri= " + uri); if (uri != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bmp.compress(Bitmap.CompressFormat.JPEG, 50, baos); byte[] bytes = baos.toByteArray(); LogUtil.i(TAG, "Bytes: " + bytes.length); ContentValues values = new ContentValues(); values.put("album_id", albumId); values.put("_data", bytes); res.insert(uri, values); } } 

This gives java.lang.UnsupportedOperationException: invalid content URI: // media / external / audio / albumart / 5

Also I tried:

 Uri artworkUri = Uri.parse("content://media/external/audio/albumart"); Uri uri = ContentUris.withAppendedId(artworkUri, album.getId()); OutputStream outStream = getContentResolver().openOutputStream(uri); bmp.compress(Bitmap.CompressFormat.JPEG, 50, outStream); 

But this gives a FileNotFoundException.

+2
android insert albumart
source share

No one has answered this question yet.

See similar questions:

6
How to update album cover path using contentResolver?

or similar:

3606
Close / hide Android soft keyboard
3295
Why is the Android emulator so slow? How can we speed up Android emulator development?
3288
Correct use cases for Android UserManager.isUserAGoat ()?
2609
Is there a unique identifier for an Android device?
2510
How to keep Android activity state by saving instance state?
2097
Is there a way to run Python on Android?
1858
"Debug certificate expired" error in Android Eclipse plugins
1844
What is "Context" on Android?
one
Android MediaStore.Images.Media.getBitmap returns an error
0
Why can't I create a content resolver

All Articles