title: Accessing contents of res/raw programmatically (Android)
body: <p>I'm working on an app for Android with a few other people, and the primary content is specified by our designers as text files in a certain file format, which we then parse, process, and serve in the app.  We're currently storing them in <code>res/raw</code>.</p>
  
  <p>This makes things great for the designers because when they want to add content, they simply add a file to <code>res/raw</code>.  This is annoying as a developer, however, since we developers then need to add <code>R.raw.the_new_file</code> to an array in the code specifying which files to process at startup.</p>
  
  <p>Is there a way to access the resource ID's of <code>res/raw</code> programatically?  Ideally when the application starts, we could make a call to see which files are in <code>res/raw</code>, process all of them, so we could eliminate the small overhead with matching up the contents of  <code>res/raw</code> with that of our array in the code.</p>
  
  <p>The most promising path I've seen is <a href="http://developer.android.com/reference/android/content/res/Resources.html#getAssets()" rel="nofollow noreferrer"><code>getAssets</code></a> from <a href="http://developer.android.com/reference/android/content/res/Resources.html" rel="nofollow noreferrer">Resources</a>, which would let me call <a href="http://developer.android.com/reference/android/content/res/AssetManager.html#list(java.lang.String)" rel="nofollow noreferrer"><code>list(String)</code></a> on the <a href="http://developer.android.com/reference/android/content/res/AssetManager.html" rel="nofollow noreferrer">AssetManager</a>, but I've had trouble getting this to work, especially since you can't directly call <code>"res/raw"</code> as your filepath (or at least, it hasn't worked when I've tried.  </p>