title: Android - Read properties file without using context
body: <p>I have a simple class which is not an activity, so I don't have access to context, but I want to read a properties file in my project (rather than on sd card).</p>
  
  <pre><code>MyClass {
  
      public static void readProperties(){
          Properties props=new Properties();
          InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("/mine.properties");
          try {
              props.load(inputStream); 
          } catch(Exception e){ 
              e.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>When I run the code though, I get a null pointer exception:</p>
  
  <blockquote>
    <p>02-20 15:32:38.396: E/AndroidRuntime(27473): java.lang.NullPointerException: in == null<br>
    02-20 15:32:38.396: E/AndroidRuntime(27473):    at java.util.Properties.load(Properties.java:246)</p>
  </blockquote>
  
  <p>Where should I put my properties file in order to be able to read it? I tried <code>src</code> , the project root, assets, and also next to MyClass.java, each time getting null pointers. What am I doing wrong?</p>
  
  <p>I'm using Eclipse with ADT (not on Android Studio yet).<br>
  My structure is something like this:</p>
  
  <blockquote>
    <p>-src<br>
       --main/SomeActivity.java<br>
       --main/MyClass.java<br>
       --main/mine.properties<br>
    -assets<br>
    -gen<br>
    -res</p>
  </blockquote>