Android - .nomedia not working for images

2019-01-17 15:28发布

I have images, which are read from sdcard only by particular application so I want to hide it from image gallery. I have put .nomedia file in it, but this file is ignored, images are still showing in Gallery. I have put it with "." in the beginning. Still not working. Any ideas?

9条回答
聊天终结者
2楼-- · 2019-01-17 16:00

With Media Storage 4.1.1 on my Samsung Galaxy Note 2, none of the tricks given above works fully, in this sense: directories containing .nomedia files are still scanned, which can drain the battery a lot (though the result is ignored in the gallery), and also directories with names starting with a '.' are still scanned :-(
I resorted to using the "Media Scanner Root" app, which allows to disable the crappy media scanner altogether. This is apparently achieved by something like

pm disable com.android.providers.media/com.android.providers.media.MediaScannerReceiver

BTW, disabling/freezing the Media Storage app itself has the bad effect that the selection and binding of ringtones and notifications does not work any more (what a wonderful design), but when only disabling its scanner component, one can still use, e.g., the ES File Explorer for selecting tones.

查看更多
闹够了就滚
3楼-- · 2019-01-17 16:01

The .nomedia bug is right and you CAN add it to a preexisting image folder.

You can force the gallery to re-index after you created the .nomedia file by renaming the folder, run gallery (the "hidden folder should now be missing), and rename the folder back to what you want. It should remain hidden.

I just did it again to ensure it works on my phone. Android 4.0.4.

查看更多
戒情不戒烟
4楼-- · 2019-01-17 16:03

Well... I admit I'm only guessing, but since it got a +1 in the comment, I'll give it a whirl as an answer. Since this is your own app, change the image file's extension to something totally unique ".myimagefile" for instance, and see if that hides it from Android. Meanwhile you know what files to load into your own app, and how to save them.

查看更多
放荡不羁爱自由
5楼-- · 2019-01-17 16:07

Here's something I found myself:

http://www.transformerforums.com/forum/asus-transformer-faq/17765-solved-nomedia-doesnt-work-under-honeycomb-ics.html

However, a little alteration to that method:

  1. Download and install SDRescan app
  2. Clear data for Gallery app
  3. Clear data for Media Storage app
  4. Open SDRescan app downloaded from step 1

SDCard should be re-scanned and all directories containing .nomedia files should be ignored at this point.

查看更多
三岁会撩人
6楼-- · 2019-01-17 16:09

In my memory card I have thousands of photos that overwhelm the media-scanner. Then in the root folder on my memory card, renamed from "RootFolder" to ".RootFolder"

Became the hidden directory and not use more .nomedia

Try this.

查看更多
男人必须洒脱
7楼-- · 2019-01-17 16:12

The .nomedia file is preventive, not curative (in Android 4.0), and it is a bug. If you had a .nomedia file and images are already in it, Gallery will still search for images.

You need to create your .nomedia file before puting images in it.

Edit: all folders starting with a dot are not scanned (because hidden).

查看更多
登录 后发表回答