I'm trying to update the genre tag of an audio file.
CODE
final Uri genreUri = MediaStore.Audio.Genres.EXTERNAL_CONTENT_URI;
String currentGenreName = MediaStore.Audio.Genres.NAME;
ContentValues values2 = new ContentValues();
values2.put(currentGenreName, genre);
String whereGenre = MediaStore.Audio.Genres._ID + "=?";
String[] whereVal2 = {Long.toString(genreID)};
resolver.update(genreUri, values2, whereGenre, whereVal2);
- genre: value from edittext (new genre name).
- genreID: genreID from selected audio file.
I'm not getting any errors, but the genre doesn't update in the MediaStore genre table.
Other tags like Title, artist, album and art are updated, only genre doesn't work.
I also can't find any information about updating the genre name in an audio file, I only managed to do it with the tags above.
EDIT
CODE I use for editing the title, artist, albumname and year tags and this works fine so I figured i had to do the same for the genre name because I have the genre id.
final Uri musicUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
ContentResolver resolver = c.getContentResolver();
String currentTitle = MediaStore.Audio.Media.TITLE;
String currentArtist = MediaStore.Audio.Media.ARTIST;
String currentAlbumID = MediaStore.Audio.Media.ALBUM_ID;
String currentAlbum = MediaStore.Audio.Media.ALBUM;
String currentGenreID = MediaStore.Audio.Genres._ID;
String currentGenreName = MediaStore.Audio.Genres.NAME;
String currentAlbumData = MediaStore.Audio.Media.DATA;
String currentYear = MediaStore.Audio.Media.YEAR;
ContentValues values = new ContentValues();
values.put(currentTitle, title);
values.put(currentArtist, artist);
values.put(currentAlbum, album);
values.put(currentYear, year);
//Update song info.
String where = MediaStore.Audio.Media._ID + "=?";
String[] whereVal = {Long.toString(songID)};
resolver.update(musicUri, values, where, whereVal);
Any reason why it's not updating?