title: How to add a song from the resource directory to a playlist
body: <p>I'm been working on a project that generates a playlist with all the songs from the external storage of the device, like this:</p>
  
  <pre><code>private long resolveContent() {
  ContentResolver contentResolver = getContentResolver();
          addMP3TestFile();
          Uri uri = android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
          Cursor cursor = contentResolver.query(uri, null, null, null, null);
  ...}
  </code></pre>
  
  <p>The code works fine, the songs display in the playlist as it suppossed, but I want to add an extra song to this playlist. This song is in the <code>res/raw/</code> directory. So I figured two solutions to this, either I copy the song to the device and let the <code>contentResolver</code> include this song to the playlist or internally add this song from the <code>res/raw/</code> directory to the playlist. I have just tried the first option I mentioned but not successfully with this code to add the song to the device:</p>
  
  <pre><code>private void addMP3TestFile(){
      String baseDir = Environment.getExternalStorageDirectory().getAbsolutePath()+"/Music/";
      String fileName = "test_file.mp3";
  
      File newSoundFile = new File(baseDir, fileName);
      if(!newSoundFile.exists()){
          try {
              byte[] readData = new byte[1024*500];
              InputStream inputStream = getResources().openRawResource(R.raw.toth);
              FileOutputStream fileOutputStream = new FileOutputStream(newSoundFile);
              int i = inputStream.read(readData);
  
              while (i != -1) {
                  fileOutputStream.write(readData, 0, i);
                  i = inputStream.read(readData);
              }
              Log.i("song","Success! path = "+newSoundFile.getAbsolutePath());
  
              fileOutputStream.close();
          } catch (IOException io) {
              Log.i("song","Error "+io.getMessage());
          }
      }
  
  
  }
  </code></pre>
  
  <p>The song copies successfully to the device, but the <code>contentResolver</code> ignores it, so the song doesn't show in the playlist. So I don't know how to resolve this, either by the first way I mentioned or the second one. I hope you have suggestions to this problem! Thanks for the attention!</p>