Why Gallery and Music app are unable to read SD card storage while a file explorer can? I checked my phone after a while (after 3 hours), and I found that all of my photos and songs were not there anymore. I checked my ES file explorer, because by default, I have  Google files (which is not a good way to manage files). I saw everything was fine in ES explorer. 

I rebooted the phone a couple of times and even pulled out and reinserted my SD card but it didn't work.

How can the problem be fixed?
Since you can access your music and pictures just fine from your file explorer, that usually means that it is being ignored by a .nomedia file.

Try to delete the .nomedia files from /sdcard, /sdcard/Music, /sdcard/Pictures, and /sdcard/DCIM.

If you have access to a terminal app on your phone, try the following commands:

cd /sdcard/ #Or  cd /mnt/sdcard or  cd /storage/sdcard0 if that doesn't work
rm -r ".nomedia"


(Note  that the above commands will delete ALL .nomedia files from your phone, so other files (from app caches) will also appear.) Alternatively, you could put your SD card in your computer, use the file manager to search for .nomedia, and delete all the .nomedia files it finds.

After deleting the .nomedia files, your Gallery and Music apps should see your pictures and music.