javaandroidjaudiotagger

Jaudiotagger change tags only after reboot device


I have this code:

 File mp3 = new File(song.getPath());
 AudioFile f = AudioFileIO.read(mp3);
 Tag tag = f.getTag();
 tag.setField(FieldKey.TITLE,songTitle.getText().toString());
 tag.setField(FieldKey.ALBUM,albumTitle.getText().toString());
 tag.setField(FieldKey.ARTIST,artistTitle.getText().toString());
 AudioFileIO.write(f);

Changes will take effect only after restart device. Do you have any idea how to fix it?


Solution

  • Send a broadcast to media scanner then refresh content resolver to be able to see changes of mp3 file.

    sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(mp3)));