title: How to monitor android device free space programatically
body: <p>I want to update and show to the user available free space of my device, I tried many ways but nothing worked, every method I used seemed to show memory only once at app start, but than every call of those methods printed the same value, there was no update
  currently I'm using this method </p>
  
  <pre><code>public long getfreeMemory() {
      StatFs statFs = new StatFs(Environment.getRootDirectory().getAbsolutePath());
      return (long) (statFs.getAvailableBlocks() * statFs.getBlockSize());
  }
  
  public void checkAppMemory() {
      Log.e("MEMORY", getfreeMemory() + "");
      memoryHandler_.postDelayed(new Runnable() {
          public void run() {
              checkAppMemory();
          }
      }, (int) (CHECK_MEMORY_FREQ_SECONDS * 1000));
  }
  </code></pre>
  
  <p>I just want to detect, when there is no available free storage, I was using BroadCastReceiver, but one device (Samsung s4 os 4.4.2) doesn't fired up memory low event</p>