Ok, I could make some tests.
Nothing wrong with the database itself, I was misleading.
Not event a problem with Music app (Eleven from LineageOS).
Let me clarify :
- I added 2 mp3 files, one in internal storage, another in SDCard :
- Internal file (Early Bird) shows immediately in Music and plays fine :
- rebooted my test device, SDCard file (Glen Campbell) won’t still show
- checked against Android media database to verify it’s not a problem with Music app :
C:\adb>adb root
C:\adb>adb shell
santoni:/ # cd /data/data/com.android.providers.media/databases
santoni:/data/data/com.android.providers.media/databases # sqlite3 external.db
SQLite version 3.22.0 2019-09-03 18:36:11
Enter ".help" for usage hints.
sqlite> select title from files where is_music=1;
Early Bird - It's Only Temporary
sqlite> .quit
Only Early Bird !
- I guess that the media scanner is not triggered when adding a file to SDCard storage, as it should be using intent or activity … Let’s keep this in a corner for a future GitLab issue
- as the database can be very large, it may take time to reconstruct at a reboot… So let’s see if we can find another solution ! Digging in XDA i came up with this https://forum.xda-developers.com/t/mod-enable-disable-media-scanning-at-boot.1409780/
- It definitively worth a try :
C:\adb>adb root
C:\adb>adb shell
santoni:/ # pm enable com.android.providers.media/com.android.providers.media.MediaScannerReceiver
Component {com.android.providers.media/com.android.providers.media.MediaScannerReceiver} new state: enabled
santoni:/ # ^D
C:\adb>adb reboot system
- it worked !
C:\adb>adb root
C:\adb>adb shell
santoni:/ # sqlite3 /data/data/com.android.providers.media/databases/external.db
SQLite version 3.22.0 2019-09-03 18:36:11
Enter ".help" for usage hints.
sqlite> select title from files where is_music=1;
Early Bird - It's Only Temporary
Glen Campbell - Rhinestone Cowboy
sqlite> .quit
santoni:/ #
- it’s not perfect, but at least we’ve got a solution here
-
if you wish to try this, please be aware that you will face the same behavior when deleting file ! For example (I deleted “Glen Campbell” from SDCard using my Windows computer, but didn’t reboot my testing device) :
- file disappears after a reboot :