Manish Karena Manish Karena - 1 year ago 79
Android Question

Prevent showing hidden files and folder to gallery in android

I am creating an project for hiding files and folder.I am able to hide folder and file from file system with below code,but it show on their any way to prevent file and folder to showing in gallery.

My code for hiding any file is:

public static void hideFile(File file){
File dstFile = new File(file.getParent(), "." + file.getName());

Please help me to solve this issue.

Answer Source

Since Gallary app is meant to show all image/media files, you can skip it accesing your files by creating .nomedia folder.

Next, place all your files, that you are planning to hide, in this folder.

.nomedia is a hint to Gallery (and other similar apps) there is no media accessible in the folder to show.

One more related point is that If the folder already contains some images before adding '.nomedia' file, the gallery will not hide those images.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download