title: android cannot get size of taken photo.. a bug?
body: <p>In my app I have options to take/select photo, audio or video files. I write each file path in its own string and perform some actions with it. Also, I use it to determine the file size with following method:</p>
  
  <pre><code>    public double getSize(String path) {
  
      File file = new File(path);
  
      if (file.exists()) {
          long size = file.length();
  
          return size;
      } else {
          Log.e("zero size", "the file size is zero!");
          return 0;
  
      }
  
  }
  </code></pre>
  
  <p>It works fine BUT the method always returns 0 while trying to get the size of a taken picture. </p>
  
  <pre><code>   double s = 1.0 * getSize(taken_pic_path) / 1024 / 1024;
  </code></pre>
  
  <p>taken_pic_path is 100% correct for 3 reasons: 1). I use the same path to create a preview and it works. 2). I let the path to be shown via a Toast and it seems to be correct 3). I check the path with file.exists() and it returns true. I also tried the following:</p>
  
  <pre><code>File file = new File(taken_pic_path);
  if (file.exists()){
     double test = file.lenght();
  }
  </code></pre>
  
  <p>I always get a zero as file size.. same technique works perfectly with taken video, taken audio, selected picture/video/audio, I'm only getting 0 while trying to get the size of a taken photo. Just can't get the reason.. Any ideas?</p>
  
  <p><strong>EDIT</strong>
  I made all possible checks:</p>
  
  <pre><code> if (file.exists()) {
  
              String b = file.getPath();
              boolean r = file.canRead();
              boolean w = file.canWrite();
              double d = file.length();
              Toast.makeText(getApplicationContext(), b, Toast.LENGTH_LONG)
                      .show();
              Toast.makeText(getApplicationContext(), Boolean.toString(r),
                      Toast.LENGTH_LONG).show();
  
              Toast.makeText(getApplicationContext(), Boolean.toString(w),
                      Toast.LENGTH_LONG).show();
              Toast.makeText(getApplicationContext(), Double.toString(d),
                      Toast.LENGTH_LONG).show();
  
          }
  </code></pre>
  
  <p>OUTPUT: correct file path / true / true / 0.0<br>
  what the hell......</p>