code: private long getAvailableInternalMemorySize() {
          final File path = Environment.getDataDirectory();
          final StatFs stat = new StatFs(path.getPath());
          final long blockSize;
          final long availableBlocks;
          if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
              blockSize = stat.getBlockSizeLong();
              availableBlocks = stat.getAvailableBlocksLong();
          } else {
              //noinspection deprecation
              blockSize = stat.getBlockSize();
              //noinspection deprecation
              availableBlocks = stat.getAvailableBlocks();
          }
          return availableBlocks * blockSize;
      }
docs: Calculates the free memory of the device. This is based on an inspection of the filesystem, which in android
  devices is stored in RAM.
  
  @return Number of bytes available.