13

I'm building an application which download images from the web and store them into my SDCard, in order to make them invisible in the gallery I put this line to generate a .nomedia file:

FileWriter f = new FileWriter("/sdcard/Android/data/CopyImage/cache/.nomedia");

the application can successfully download the image and make the .nodata file on the same folder, but the thing is, the image is still appear on the gallery.

How could that be? Can anybody provide me a solution?

Thank you very much

hectichavana
  • 1,436
  • 13
  • 41
  • 71

3 Answers3

9

Add a "." to the beginning of folder name instead.

BTW which phone is giving u this issue. My guess is that ur seeing old cached files in the Gallery

the100rabh
  • 4,077
  • 4
  • 32
  • 40
  • 1
    Using CyanogenMod 7 this is not working... the folder name starts with a dot and the .nomedia file exists too, when rebooting the images does not appear in gallery, but as far as I go to the folder and view one of those images the whole content will appear in gallery even if I open Gallery from the homescreen – markuz Sep 14 '11 at 18:06
  • I guess u should report this behavior as a bug to CynogenMod, those fine folks there would be more than happy to fix it. – the100rabh Sep 15 '11 at 15:09
8

The .nomedia file has to be the first file in a folder in order to ignore media there. If files are already indexed, just rename such folders forth and back (opening the Gallery in the middle) and there you go.

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
  • 1
    This is useful if you're having .nomedia woes and aren't writing an app; for example the Teamspeak Android client makes an icons folder w/out a .nomedia file. You can't just change the folder name, but if the folder's already been indexed the .nomedia file might not work immediately. FWIW, the "QuickPic" app (free @ Play Store) has an option to hide folders, which generates the .nomedia file for you; Gallery may still ignore it, but QuickPic always respects the .nomedia file immediately - also has a "show hidden" option to see folders you've previously hidden w/out removing the .nomedia file. – Doktor J Mar 21 '13 at 16:33
  • It's working well, just rename that folder, open gallery and back to rename again, thx – Nullpointer Jun 18 '21 at 17:29
2

After you created the ".nomedia" file, you must reboot you phone and then the images of the folder will not appear on the gallery.

user
  • 86,916
  • 18
  • 197
  • 190
alan wang
  • 59
  • 1