1

I am trying to develop android application for hiding folders.

I used file.renameTo(new File("." + file.getName())); In Log i'm getting folder name with prefix dot(.), But Still folder is not hidden.

On Clicking the folder in recycler view I am trying to hide the folder which is clicked.

Also If folder is already hidden I am trying to un hide it.

foldersHolder.folderRow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                File file = new File(folderNames.get(position));
                if(!file.isHidden()) {
                    file.renameTo(new File("." + file.getName()));
                    Toast.makeText(context, file.getName() + " is Hidden", Toast.LENGTH_SHORT).show();
                }
                else {
                    file.renameTo(new File(file.getName().substring(1)));
                    Toast.makeText(context, file.getName() + " is Shown", Toast.LENGTH_SHORT).show();
                }

            }
        });

Please help!

Arjun G
  • 544
  • 1
  • 6
  • 18

1 Answers1

1

Create a folder with a . (dot) before its name, and add an empty .nomedia file inside it. (.(dot)nomedia - exactly as I typed it) and add your files ands images there.

Now other Apps like Gallery will ignore these images. That's the only way that I think this can be done.

E.g.: folder name: .images

which includes an empty file .nomedia

Jay Patel
  • 1,051
  • 8
  • 24