What Is a .NOMEDIA File?
Your photos or music vanished from the Gallery but the files are still there. A .nomedia file is hiding that folder. Here is how it works.
What a .nomedia file is
A .nomedia file is an empty marker file that tells Android's media scanner to skip a folder. Any images, music or videos in a folder containing .nomedia won't appear in Gallery, the music player, or other media apps — the files are still there, just hidden from those apps.
Why a folder went missing from Gallery
An app (or you) placed a .nomedia in it. WhatsApp, cache folders and some downloaders add one automatically.
How to unhide the folder
Use a file manager that shows hidden files, open the folder, and delete the .nomedia. Then rescan (reboot, or clear the media store cache) and the files reappear in Gallery.
How to hide a folder
Create an empty file named exactly .nomedia (with the leading dot, no extension) inside it.
FAQ
How do I remove a .nomedia file?
Use a file manager with 'show hidden files' enabled, open the folder, and delete the .nomedia file, then rescan or reboot.
Why did my pictures disappear from Gallery?
A .nomedia file in that folder tells Android to skip it. The photos are still there; delete the .nomedia to show them.
How do I hide a folder with .nomedia?
Create an empty file named exactly .nomedia inside the folder.