title: Android access to resources outside of activity
body: <p>I would like to know - are there ways to access android resources and/or assets files (or files from any other folder) outside of an Activity (<em>without passing context</em>)? </p>
  
  <p>Can't access without context:</p>
  
  <pre><code>getResources().getIdentifier("resource_name", "drawable", getPackageName());
  getAssets().open("file_in_assets_folder_name");
  </code></pre>
  
  <p>Throws Exception if not in Activity:</p>
  
  <pre><code>try {
      Class class = R.drawable.class;
      Field field = class.getField("resource_name");
      Integer i = new Integer(field.getInt(null));
  } catch (Exception e) {}
  </code></pre>
  
  <p>Also tried the below, but it complains file doesn't exist (doing something wrong here?):</p>
  
  <pre><code>URL url = new URL("file:///android_asset/file_name.ext");
  InputSource source = new InputSource(url.openStream());
  //exception looks like so 04-10 00:40:43.382: W/System.err(5547): java.io.FileNotFoundException: /android_asset/InfoItems.xml (No such file or directory)
  </code></pre>