To hide photos from your gallery app without deleting them, place a .nomedia file in the folder that contains those photos. Android's media scanner will skip the entire folder, making its contents invisible to Google Photos, Samsung Gallery, and every other media-browsing app — while the actual files remain untouched and fully accessible through file managers like AnExplorer.
Why Gallery Apps Show Everything
Android maintains a system-wide media database called MediaStore. Whenever files change on your device, the media scanner crawls storage directories and indexes every image, video, and audio file it finds. Gallery apps read from this index rather than scanning the filesystem themselves. This means:
- Every photo in
DCIM/,Pictures/,Download/, and similar folders gets indexed automatically - Screenshots, app-saved images, memes, work documents with image previews — everything appears in your gallery
- You cannot selectively exclude files from the gallery through the gallery app itself (most galleries lack this feature)
The solution is controlling what the media scanner indexes, not what the gallery displays.
Method 1: The .nomedia File (Best for Folders)
The .nomedia file is an empty marker file recognized by Android's media scanner. When the scanner encounters a folder containing a .nomedia file, it skips the entire folder and all subfolders within it. No images, videos, or audio files from that directory tree will appear in any media app.
Creating a .nomedia File with AnExplorer
- Open AnExplorer and navigate to the folder containing photos you want hidden
- Tap ⋮ (Menu) → New → File
- Name the file:
.nomedia(the leading dot is mandatory) - The file content does not matter — it can be empty (0 bytes)
- Tap Create or OK
If your device shows an error for filenames starting with a dot:
- Create a file named
nomedia(without the dot) - Long-press the file → Rename
- Change the name to
.nomedia
Verifying It Works
After creating the .nomedia file:
- Force-close your gallery app: Settings → Apps → Gallery App → Force Stop
- Reopen the gallery app
- The photos from that folder should no longer appear
- If they still show, clear the gallery app's cache: Settings → Apps → Gallery App → Storage → Clear Cache
- As a last resort, reboot your phone to trigger a full media re-scan
The photos are still physically present — open AnExplorer and navigate to the folder to confirm they are unchanged.
Method 2: Move Photos to a Hidden Folder
Instead of adding .nomedia to an existing folder, create a dedicated hidden folder for private photos:
- Open AnExplorer → navigate to Internal Storage
- Create a new folder named
.privateor.hidden_photos(starting with a dot) - The dot prefix makes the folder itself hidden from casual browsing
- Create a
.nomediafile inside this folder (for double protection) - Move your private photos into this folder using AnExplorer's move function
This gives you two layers of privacy:
- The folder is hidden (invisible without "Show Hidden Files" enabled)
- The
.nomediafile prevents media indexing even if someone enables hidden files
Organizing Hidden Photos
Create subfolders within your hidden directory to stay organized:
.private/
├── .nomedia
├── personal/
├── documents/
└── screenshots/
The .nomedia file in the parent folder cascades to all subfolders, so you only need one.
Method 3: Rename Files with Dot Prefix
For individual files rather than entire folders, you can hide specific photos by renaming them with a dot prefix:
- Open AnExplorer → navigate to the photo
- Long-press → Rename
- Change
photo.jpgto.photo.jpg - The file is now hidden from media scanning AND from file manager browsing (unless Show Hidden Files is enabled)
This method is tedious for many files but precise for hiding specific images without moving them.
Method 4: Use Android's Built-in Secure Folder (Samsung)
Samsung devices include a Secure Folder feature powered by Knox:
- Open Settings → Biometrics and security → Secure Folder
- Sign in with your Samsung account and set a PIN/pattern/biometric
- Open Secure Folder → tap Add files → Images
- Select photos to move into the encrypted container
- Choose Move (not Copy) to remove them from the regular gallery entirely
Secure Folder stores files in an encrypted partition that requires authentication to access. This is more secure than .nomedia because the files are actually encrypted, not just hidden from indexing.
Limitations of Secure Folder
- Samsung only (not available on Pixel, OnePlus, Xiaomi, etc.)
- Files inside cannot be accessed by any file manager including AnExplorer (by design)
- If you forget your PIN and Samsung account password, files are permanently inaccessible
- Factory reset destroys Secure Folder contents
Method 5: Google Photos Locked Folder (Pixel and Others)
Google Photos includes a Locked Folder feature on Pixel devices and many others:
- Open Google Photos → Library → Utilities → Locked Folder
- Set up with your screen lock (PIN/pattern/fingerprint)
- Move photos into the Locked Folder
- These photos are removed from the main gallery, not backed up to cloud, and require authentication to view
This is convenient but limited:
- Photos in Locked Folder are NOT backed up (risky if phone is lost)
- Cannot be accessed from file managers
- Only works within Google Photos itself
Comparing All Methods
| Method | Security Level | Ease of Use | Works System-Wide | Recoverable |
|---|---|---|---|---|
| .nomedia file | Low (hides from gallery only) | Easy | Yes | Yes — delete the .nomedia file |
| Hidden folder (.dot prefix) | Low-Medium | Easy | Yes | Yes — enable hidden files |
| File rename (.prefix) | Low | Tedious | Yes | Yes — rename back |
| Samsung Secure Folder | High (encrypted) | Medium | Samsung only | Only with Samsung account |
| Google Locked Folder | Medium | Easy | Google Photos only | Only with screen lock |
Important Warnings
.nomedia Does NOT Provide Security
The .nomedia file only controls media indexing — it does not encrypt, lock, or protect files in any way. Anyone who opens a file manager and enables "Show Hidden Files" can see everything. For actual security:
- Use encrypted archives (ZIP with password via AnExplorer)
- Use Samsung Secure Folder or similar encrypted containers
- Use AnExplorer's file encryption feature if available
Cloud Backup Complications
If you use Google Photos auto-backup:
- Photos backed up BEFORE adding
.nomediaremain in the cloud - Adding
.nomediaprevents FUTURE backups from that folder - To fully hide photos from cloud, delete them from Google Photos web (photos.google.com) after adding
.nomedialocally - Google Photos Locked Folder explicitly does not sync to cloud
Gallery Apps Cache Previous Scans
After adding .nomedia, photos may still appear in your gallery temporarily because:
- Gallery apps cache thumbnails and metadata
- The media scanner runs periodically, not instantly
- Force-stopping the gallery and clearing its cache speeds up the process
- A full device reboot guarantees a fresh media scan
Troubleshooting
Added .nomedia but photos still show in gallery
- Confirm the file is named exactly
.nomedia(not.nomedia.txtornomedia) - Confirm it is in the correct folder (same directory as the photos, not a subfolder)
- Force-stop the gallery app and clear its cache
- Reboot the phone
- If using Google Photos, check that you are not seeing cloud-synced copies
.nomedia file keeps disappearing
Some apps (particularly those that write media to folders) delete .nomedia files they find. WhatsApp, for example, may recreate its media folders without the .nomedia file after updates. Solutions:
- Make the
.nomediafile read-only (requires root or ADB) - Move private photos to your own folder structure instead of modifying app folders
- Check periodically if the
.nomediafile is still present
Cannot create a file starting with dot
Some Android versions or launchers restrict dot-prefix filenames in certain creation dialogs. Use AnExplorer's file creation which supports dot-prefixed names, or create the file without the dot and rename it afterward.
Related Guides
- Access Hidden Files — show/hide dotfiles in AnExplorer
- Photos Not Showing in Gallery — reverse problem: make photos appear
- Hide Files on Android — general file hiding methods
- Encrypt Files on Android — password-protect sensitive files