title: How to merge two or more mp3 audio file in android?
body: <p>I'm trying to merge mp3 audio files But not successful. </p>
  
  <p>Here is my code.</p>
  
  <pre><code>public static void meargeAudio(List&lt;File&gt; filesToMearge)
  {
  
  
      while (filesToMearge.size()!=1){
  
          try {
              FileInputStream fistream1 = new FileInputStream(new File(filesToMearge.get(0).getPath()));  //(/storage/emulated/0/Audio Notes/1455194356500.mp3) first source file
              FileInputStream fistream2 = new FileInputStream(new File(filesToMearge.get(1).getPath()));//second source file
  
              File file1 = new File(filesToMearge.get(0).getPath());
              boolean deleted = file1.delete();
              File file2 = new File(filesToMearge.get(1).getPath());
              boolean deleted1 = file2.delete();
  
              SequenceInputStream sistream = new SequenceInputStream(fistream1, fistream2);
              FileOutputStream fostream = new FileOutputStream(new File(filesToMearge.get(0).getPath()),true);//destinationfile
  
              int temp;
  
              while ((temp = sistream.read()) != -1) {
                  // System.out.print( (char) temp ); // to print at DOS prompt
                  fostream.write(temp);   // to write to file
              }
  
              filesToMearge.add(0,new File(filesToMearge.get(0).getPath()));
              filesToMearge.remove(1);
              filesToMearge.remove(1);
  
  
              fostream.close();
              sistream.close();
              fistream1.close();
              fistream2.close();
          } catch (IOException e) {
              e.printStackTrace();
          }
      }
  
  }
  </code></pre>
  
  <p>e.g </p>
  
  <p>firstFileSize =12kb</p>
  
  <p>secondFileSize =10kb</p>
  
  <p>finalfileSize=22kb</p>
  
  <p>Size is accurate But sound is missing</p>
  
  <p>No error but in result i found finalfile contains only first file audio second file audio is missing.</p>
  
  <p>Don't know what is the issue.if any one know the solution help me.</p>
  
  <p>Thanks </p>