title: android share audio file from assets folder
body: <p>I can't share audio file from assets.
  Each app says that it can't send the file.</p>
  
  <p>Method for converting inputstream to temporary file</p>
  
  <pre><code>    public File getFile(String Prefix, String Suffix) throws IOException {
  
      File tempFile = File.createTempFile(Prefix, Suffix);
      AssetFileDescriptor tempafd = FXActivity.getInstance().getAssets().openFd(filepath);
      tempFile.deleteOnExit();
      FileOutputStream out = new FileOutputStream(tempFile);
      IOUtils.copy(tempafd.createInputStream(), out);
  
  
      return tempFile;
  }
  </code></pre>
  
  <p>Sharing file</p>
  
  <pre><code>        item2.setOnAction(n -&gt;{
              try {
                  Uri uri = Uri.fromFile(tekst.getFile(tekst.getFilename(), ".mp3"));
                  Intent share = new Intent();
                  share.setType("audio/*");
                  share.setAction(Intent.ACTION_SEND);
                  share.putExtra(Intent.EXTRA_STREAM, uri);
                  FXActivity.getInstance().startActivity(share);
              } catch (IOException ex) {
                  Logger.getLogger(MainCategoryCreator.class.getName()).log(Level.SEVERE, null, ex);
              }
  
          });
  </code></pre>