If a file called .nomedia gets put into a directory, the Media Scanner skips that directory, e.g. sprite images.

Does that also work if .nomedia is a folder?

1 Answer 1


Yes. If a folder contains another folder that is named .nomedia, the parent folder will be ignored.

The relevant code is here (note to the confused: File doesn't necessarily be a regular file - in Linux directories are just special files).

One of my favorite IME app also creates folders of this name (instead of files) in its asset folders - the assets are ignored by MediaScanner.

Trivia: If you managed to put other special files like symbolic links or named pipes (FIFOs) with the name .nomedia, it will also work. (Spoiler: indeed you can, but you need root).

An alternative way, as suggested by beeshyams, is to rename the parent folder and make it start with a dot. This has the same effect as having a .nomedia inside it, as both ways make the code return true (should be ignored).

  • 4
    +1. i didn't know that !
    – beeshyams
    Dec 16, 2018 at 13:40
  • 1
    I don't think the "note to the confused" is especially un-confusing. java.io.File is not Android or Linux specific, and can just represent any pathname, including a directory name, on any system, eg. on Windows. Dec 17, 2018 at 8:31
  • @MichałPolitowski I myself don't even have any Java experience! But anyway, a non-programmer would possibly think a File is a file, no?
    – iBug
    Dec 17, 2018 at 9:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .