title: Sending a renamed file using Intent.ACTION_SEND
body: <p>Let's say I have a save file, <code>saves.xyz</code>, and I want to share it, by mail.</p>
  
  <pre><code>Intent intent = new Intent(Intent.ACTION_SEND);
  intent.putExtra(Intent.EXTRA_SUBJECT, content.getShareSubject());
  intent.putExtra(Intent.EXTRA_TEXT, content.getShareText());
  
  File savesFile = new File(Environment.getExternalStorageDirectory(), filePath);
  Uri savesUri = Uri.fromFile(savesFile);
  intent.putExtra(Intent.EXTRA_STREAM, savesUri);
  
  String fileType = activity.getString(R.string.saves_file_type); //"text/xyz"
  intent.setType(fileType);
  
  String chooserMessage = activity.getString(R.string.saves_chooser_message);
  activity.startActivity(Intent.createChooser(intent, chooserMessage));
  </code></pre>
  
  <p>This works fine enough.</p>
  
  <hr>
  
  <p>However, I now want to be able to <strong>rename the attached file</strong> (say <code>saves-01-01-2017.xyz</code>).</p>
  
  <p>I've thought about copying the file, sending it, then deleting it, but haven't found a way to delete it cleanly afterwards (see <a href="https://stackoverflow.com/q/23222702/7041501">this</a>).</p>
  
  <p>I also tried to implement my own <code>FileProvider</code> (as advised <a href="https://stackoverflow.com/q/14099252/7041501">here</a>) and redirecting <code>saves-*.xyz</code> to <code>saves.xyz</code>, but I couldn't get the <code>FileProvider</code> to work (I probably didn't grasp their function fully) :</p>
  
  <p><strong>manifest.xml</strong></p>
  
  <pre><code>&lt;manifest 
      xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.mydomain.myapp"
      &gt;
      ...
      &lt;application
          ...
          &gt;
          &lt;provider
              android:name="com.mydomain.myapp.MyFileProvider"
              android:authorities="com.mydomain.fileprovider"
              android:exported="false"
              android:grantUriPermissions="true"
              &gt;
              &lt;meta-data
                  android:name="android.support.FILE_PROVIDER_PATHS"
                  android:resource="@xml/file_provider_paths"
              /&gt;
          &lt;/provider&gt;
          ...
      &lt;/application&gt;
  &lt;/manifest&gt;
  </code></pre>
  
  <p><strong>file_provider_paths.xml</strong></p>
  
  <pre><code>&lt;paths xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;files-path 
          name="saves_folder"
          path="/"
      /&gt;
  &lt;/paths&gt;
  </code></pre>
  
  <p><strong>MyFileProvider class</strong></p>
  
  <pre><code>public class MyFileProvider extends FileProvider {
      @Override
      public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
          //doesn't print anything
          Log.d(MyFileProvider.class.getSimpleName(), uri.toString()); 
          return super.openFile(uri, mode);
      }
  }
  </code></pre>
  
  <p>I'd be grateful if I were to be enlightened here.</p>