title: Get Uri from file I just created (android)
body: <p>forgive me for what is probably a stupid question, but I really can't find the answer anywhere.</p>
  
  <p>I need my program to save the contents of an EditText as an html file and share it with other applications. To do this, I need to write the file to internal storage and then get the URI to it. However, there is no information anywhere (that I could fine) on how to do that.</p>
  
  <p>This is my code (Editor being the name of the Activity and myapp the package):</p>
  
  <pre><code>String filename = "Lorem ipsum.html";
  
              FileOutputStream outputStream;
  
              try {
                  outputStream = openFileOutput(filename, Context.MODE_PRIVATE);
                  outputStream.write(Html.toHtml(textField.getText()).getBytes());
                  outputStream.close();
                  System.out.println(filename);
              } catch (Exception e) {
                  e.printStackTrace();
              }
  
                  Intent shareIntent = ShareCompat.IntentBuilder.from(Editor.this)
                          .setStream(FileProvider.getUriForFile(Editor.this, "com.myapp.fileprovider", new File(filename)))
                          .getIntent();
                  shareIntent.setData(FileProvider.getUriForFile(Editor.this, "com.myapp.fileprovider", new File(filename)));
                  shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
              startActivity(shareIntent);
  </code></pre>
  
  <p>As far as I can tell, the file creation part works just fine; no exception is caught. However, the actual sharing part crashes with this error:</p>
  
  <pre><code>java.lang.IllegalArgumentException: Failed to find configured root that contains /Lorem ipsum.html
  </code></pre>
  
  <p>I'm clearly doing something wrong when trying to find the URI, but I've been unable to find a solution. Following the official documentation did not help and I could find no examples of this specific problem.</p>
  
  <p>If it matters, here is my fileprovider declaration:</p>
  
  <pre><code>&lt;provider
          android:name="android.support.v4.content.FileProvider"
          android:authorities="com.myapp.fileprovider"
          android:exported="false"
          android:grantUriPermissions="true"&gt;
          &lt;meta-data
              android:name="android.support.FILE_PROVIDER_PATHS"
              android:resource="@xml/paths" /&gt;
      &lt;/provider&gt;
  </code></pre>
  
  <p>Thank you in advance for any help.</p>