title: Play mp3 sounds from SD card
body: <p>I have a directory on my tablet's SD card called "/Android/data/com.example.android.app/files".  I just created it manually because I don't know how else to test this aspect of my app.  I have filenames stored in a sqlite database like "/folder1/audio1.mp3", "/folder2/audio1.mp3", etc...  The files have the same names, but are in different folders, as they are the same thing is different languages.  I have those folders (folder1 and folder2) and all of the mp3 files in the "/Android/data/com.example.android.app/files" directory on the SD card.</p>
  
  <p>So, I get the file names from the database and I TRY to get to the folder on the SD card with:</p>
  
  <pre><code>String baseDir = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Android/data/com.example.android.app/files";
  </code></pre>
  
  <p>Which just basically ends up making the path "storage/Android/data/com.example.android.app/files".</p>
  
  <p>Now, I DID have a few mp3 files in my raw folder during early development, but there will be too many files in the end to keep in that folder, so I started investigating getting them from the SD card.  When I had them in raw, I got them like this:</p>
  
  <pre><code>rid = getResources().getIdentifier(filname,  "raw", "com.example.android.app");
  </code></pre>
  
  <p>Now, with the files on the SD card, that changes to:</p>
  
  <pre><code>filename = "/folder1/audio.mp3"
  </code></pre>
  
  <p>and instead of "raw" I have:</p>
  
  <pre><code>"storage/Android/data/com.example.android.app/files"
  </code></pre>
  
  <p>and basically played them like this:</p>
  
  <pre><code>AssetFileDescriptor afd = mContext.getResources().openRawResourceFd(rid);
  mMP.reset();
  mMP.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getDeclaredLength());
  mMP.prepare();
  mMP.start();
  afd.close();
  </code></pre>
  
  <p>However none of this approach seems to work the same way now.</p>
  
  <p>Can you get the resourceid from an mp3 file on the SD card?  Is that even the appropriate way for me to do it now?  Is there a different way I should be playing them that will work whether the source is internal or external memory?</p>
  
  <p>Thoroughly confused.</p>
  
  <p>EDIT:
  I did find <a href="http://www.41post.com/3985/programming/android-loading-files-from-the-assets-and-raw-folders">this</a> which might help...but it's maybe only have of the equation.</p>
  
  <p>EDIT2:
  And I'm looking <a href="http://developer.android.com/resources/samples/RandomMusicPlayer/index.html">here</a>.  It uses mediastore which I don't think is what I want.</p>