title: Nullpointer exception in android API level 21
body: <p>In my application I am using following code:</p>
  
  <pre><code> final String cachePath = Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) ||
              !Environment.isExternalStorageRemovable() ? getExternalCacheDir(context).getPath()
              : context.getCacheDir().getPath();
  </code></pre>
  
  <p>Above code run fine on android version pre lolipop, But on API level 21 I am getting dollowing error as:</p>
  
  <pre><code> java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.io.File.getPath()' on a null object reference
  </code></pre>
  
  <p>Any suggestion will  be appreciated.  Thanks in advance.</p>