title: Environment.getExternalStorageDirectory() return null
body: <p>I m trying to get the Internal Storage path of a Android Device.</p>
  
  <p>Since most of the devices late off return Internal Storage path using <code>Environment.getExternalStorageDirectory().getPath();</code> so I am using this to get the path.</p>
  
  <p>Every thing is working fine except that when I am calling <code>Environment.getExternalStorageDirectory().getPath();</code> from an non Activity class it is returning null whereas if I call it from a Activity class it returns the correct path.</p>
  
  <p>I Tried searching other posts but could not find anything useful.</p>
  
  <p>Any help would be really grateful.</p>
  
  <p><strong>EDIT:</strong>  </p>
  
  <pre><code>if(getExtSdCardPath(con)!=null)
      {  path=getExtSdCardPath(con);
  
          if(new File(path).getPath().equal(Environment.getExternalStorageDirectory().getPath())) // This line give null "Null Pointer exception"
          {
              return  null;
          }
          return path;
      }
  </code></pre>
  
  <p>I am checking if the SD Card path is same as the path which is returned by <code>Environment.getExternalStorageDirectory().getPath()</code></p>