title: Take photo with Camera and save in FileProvider
body: <p>I need help on taking a Photo in Android (in Java) using a FileProvider.
  I wrote the Android tutorial (+ much more) on taking photos, so I ended up with the following situation:
  My manifest:</p>
  
  <pre><code>    &lt;provider
          android:name="androidx.core.content.FileProvider"
          android:authorities="${applicationId}.fileprovider"
          android:exported="false"
          android:grantUriPermissions="true"&gt;
          &lt;meta-data
              android:name="android.support.FILE_PROVIDER_PATHS"
              android:resource="@xml/file_paths"&gt;
          &lt;/meta-data&gt;
      &lt;/provider&gt;
  </code></pre>
  
  <p>My res/xml/file_paths.xml:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;paths xmlns:android="http://schemas.android.com/apk/res/android"&gt;
          &lt;external-files-path
              name="schede_images"
              path="Android/data/com.android.example/files/Pictures" /&gt;
      &lt;/paths&gt;
  </code></pre>
  
  <p>Then, the method for callying the Camera Intent:</p>
  
  <pre><code>    String currentPhotoPath;
      @OnClick(R.id.startCamera)
      public void startCamera(View v) {
          File imagesFolder = new File(Environment.getExternalStorageDirectory(), "provaprovaprova");
          if (!imagesFolder.exists()) {
              boolean isCreated = imagesFolder.mkdirs();
              if (!isCreated) {
                  Toast.makeText(this, "Errore storage", Toast.LENGTH_LONG).show();
                  return;
              }
          }
          String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
          String imageFileName = "IMG_" + timeStamp + "_";
          File storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
          try {
              File image = File.createTempFile(imageFileName, ".jpg", storageDir);
              Uri uri = FileProvider.getUriForFile(this, BuildConfig.APPLICATION_ID+".fileprovider", image);
              currentPhotoPath = image.getAbsolutePath();
              Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
              intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
              startActivityForResult(intent, Util.getResources().getInteger(R.integer.ACTION_FOTO_CAPTURE));
          } catch (IOException e) {
              e.printStackTrace();
          }
      }
  </code></pre>
  
  <p>Finally, the onActivityResult:</p>
  
  <pre><code>if (requestCode == Util.getResources().getInteger(R.integer.ACTION_FOTO_CAPTURE)) {
      doSomething();
  }
  </code></pre>
  
  <p>The problem is that, in the method startCamera, on the 14th line:</p>
  
  <pre><code>    Uri uri = FileProvider.getUriForFile(this, BuildConfig.APPLICATION_ID+".fileprovider", image);
  </code></pre>
  
  <p>I have an IllegalArgumentException:</p>
  
  <pre><code>E/AndroidRuntime: FATAL EXCEPTION: main
      Process: com.android.example, PID: 25184
      java.lang.IllegalArgumentException: Failed to find configured root that contains /storage/sdcard/Android/data/com.android.example/files/Pictures/IMG_20191113_152356_376811633.jpg
          at androidx.core.content.FileProvider$SimplePathStrategy.getUriForFile(FileProvider.java:739)
          at androidx.core.content.FileProvider.getUriForFile(FileProvider.java:418)
  </code></pre>