I have been trying to update audio file metadata in android's MediaStore.
I'm setting MediaStore.Audio.Media.IS_PENDING to 1 before updating the value. In android 10, it works well but in Android11, metadata update is not wokring even with IS_PENDING.
Here is the code that I'm using,
val contentValues = ContentValues()
if (hasQ()) {
contentValues.put(MediaStore.Audio.Media.IS_PENDING, 1)
application.contentResolver.update(uri, contentValues, null, null)
}
contentValues.clear()
if (hasQ()) contentValues.put(MediaStore.Audio.Media.IS_PENDING, 0)
with(editTrackTagInfo) {
title?.let { it -> contentValues.put(MediaStore.Audio.Media.TITLE, it) }
album?.let { it -> contentValues.put(MediaStore.Audio.Media.ALBUM, it) }
artist?.let { it -> contentValues.put(MediaStore.Audio.Media.ARTIST, it) }
}
val rowsUpdated = application.contentResolver.update(uri, contentValues,
null, null)
For android 11, rowsUpdated is mostly 0. And at few times it comes out to be 1 but even in that case no metadata is updating.