How do I save an image to a folder newly created by my code?

1

I have problems when storing my photo, I create a folder using mkdir and through a string, I get the contents of an EditText from my application, to give the name of the folder. After starting the camera I wanted to save the photo in the same folder created, so I use the same string to save it:

        @Override
        public void onClick(View arg0){

        nome = nomeNovo.getText().toString();      

        File folder = new File("sdcard/" + nome);

        if (!folder.exists()){                
            pasta = folder.mkdir();            
        }             

        if (pasta == false){                
            linear.addView(teste);                
            }
        else {
            Intent intent = new Intent (MediaStore.ACTION_IMAGE_CAPTURE);
            startActivity(intent);
        //    Toast.makeText(getApplicationContext(), "Endereço: sdcard/" + nome , Toast.LENGTH_SHORT).show();
            File arquivo = new File("sdcard/" + nome);
        }

The problem is that the photo is still stored in the camera folder, not the folder I created.

    
asked by anonymous 03.11.2016 / 19:53

1 answer

0

Here's an example to open the camera and save with the name you want.

File file = new File(Environment.getExternalStorageDirectory() + "/arquivo.jpg");
Uri outputFileUri = Uri.fromFile(file);
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);

After you take the picture it will save it in the path that you pass in new File()

    
03.11.2016 / 21:24