Reputation: 25
I have an application which has loads of pictures. The total picture is saved in an SD card due to large number of picture. The main problem is that the pictures are available in gallery. I want a way to hide the picture from the gallery but must be available for my application.
I did put " . " in front of the file name to make it hidden but the images were not displayed in may application also!
Anyone.. help.. please
thanks..
Upvotes: 1
Views: 1224
Reputation: 75629
Gallery handles all media files it knows about, so if you want it to stay away of your assets you got two solutions. First, add .nomedia
file to the folder with your images, and Gallery should skip it (most image viewers would honor .nomedia
, yet there's no guarantee). Other solution is to use some own, proprietary file format, so Gallery or other tools won't be able to process it. I'd recomment .nomedia
if that's sufficient solution.
Upvotes: 3
Reputation: 546
This line of code can add the .nomedia file in your directory and makes your images hidden from the gallery
String NOMEDIA=" .nomedia";
File Folder = new File(Environment.getExternalStorageDirectory() + "/mydir"); if(Folder.mkdir()) { nomediaFile = new File(Environment.getExternalStorageDirectory() + "/mydir/"+ NOMEDIA); if(!nomediaFile.exists()){ nomediaFile.createNewFile(); } }
Upvotes: 1
Reputation: 542
Add .nomedia file into the image folder. The important thing is that, the folder should be empty, when you add .nomedia file. If the folder contains some images before adding '.nomedia' file, the gallery will not hide those images, and it will hide the images added after '.nomedia' file. So The first file added to the image folder should be '.nomedia'.
Hope dis will help you
Thankx,
Upvotes: 1
Reputation: 12444
i think the place where you save the images matter, try to save them into application cache directory, or files directory.
you can get access to cache directory using : getCacheDir()
in your activity.
and your files directory: getFilesDir()
these two directories must not be visible or accessible to any other applications expect your application,
Upvotes: 0