开发者

nomedia file in cache folders (Android)

I'm trying to create a .nomedia file into cache folder with following code

private static final String NOMEDIA_FILE = ".nomedia";
    path = new File开发者_如何学Python(Environment.getExternalStorageDirectory().getAbsolutePath()+"/Android/data/"+cnt.getApplicationInfo().packageName+"/cache/");
    path.mkdirs();

    file= new File(path,NOMEDIA_FILE);
    if (!file.exists()){
        try {
            file.createNewFile();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

file.createNewFile() returns true, later file.exists() return true, but the file dont appears at the folder. If I use another path the snipplet works. Are the cache folders automatically ignored in media scan? If not, how can I make the .nomedia file in there?

Thanks


The file does exist but is hidden in default directory lists; that's what the prefixed period (.) does.

Confirm from the command line by starting an adb shell and using ls -a to show all files. It would look something like this:

C:\Users>adb shell
root@android:/ # cd /sdcard/learnpad
root@android:/sdcard/learnpad # ls -a
.nomedia
data.learnpad.co
profile.xml


The file does exist.

It is your file explorer's settings that determine if you can see a hidden folder or not.

Just open your file explorer, go to settings, and turn on "show hidden folders"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜