"Private mode" storage of Photos

1

Well I want to take a Photo and save it without the photo being shown from the gallery. this is the code I use:

File MiFotoTemporal = new File(RUTAFOTO+ NOMBREFOTO);
MiFotoTemporal.createNewFile();
Uri uri = Uri.fromFile(MiFotoTemporal);
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);  
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);          
startActivityForResult(cameraIntent, requestCode_tomarFoto);
    
asked by Lui5 11.10.2017 в 19:04
source

2 answers

3

You should simply include an empty file called .nomedia in the folder where you save the photos. Doing something like this:

        //ruta de la carpeta donde guardes las fotos
        String rutacarpeta = Environment.getExternalStorageDirectory() + "/carpetanueva/";
        //file ruta + .nomedia
        File file = new File(rutacarpeta + ".nomedia");
        //comprueba si existe o no el archivo
        if (!file.exists()) {
            //si no existe, lo crea
            try {
                file.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

Having that file in your folder, no gallery should show the photos.

I imagine you already know that you are saving the photos but just in case, remember that from Android 5.0 , you need to ask for the permissions, in this storage case

    
answered by 11.10.2017 / 19:50
source
0

It worked for me Perfect to use the ".nomedia" file inside the folder Additionally in my case the change in my apks of Galerias is not reflected

To see the change reflected in the Gallery applications, I did the following Clear Data and Force Stop the Application Configuration > Applications > Gallery > Storage and Clear Data

    
answered by 11.10.2017 в 23:45