title: android.text.format.Formatter.formatFileSize() returns wrong format
body: <p>Here I compare Android built-in method to format file and custom from <a href="https://stackoverflow.com/a/5599842/7767664">https://stackoverflow.com/a/5599842/7767664</a></p>
  <pre><code>Timber.d(
      &quot;Format file size using Formatter.formatFileSize &quot; +
              &quot;${Formatter.formatFileSize(this, 1_000_000_000L)}, &quot; +
              &quot;${Formatter.formatFileSize(this, 1_073_741_824L)}&quot;
  )
  
  Timber.d(
      &quot;Format file size using readableFileSize &quot; +
              &quot;${readableFileSize(1_000_000_000L)}, &quot; +
              &quot;${readableFileSize(1_073_741_824L)}&quot;
  )
  </code></pre>
  <p>.</p>
  <pre><code>fun readableFileSize(size: Long): String? {
      if (size &lt;= 0) return &quot;0&quot;
      val units = arrayOf(&quot;B&quot;, &quot;kB&quot;, &quot;MB&quot;, &quot;GB&quot;, &quot;TB&quot;)
      val digitGroups = (log10(size.toDouble()) / log10(1024.0)).toInt()
      return DecimalFormat(&quot;#,##0.#&quot;).format(size / 1024.0.pow(digitGroups.toDouble()))
          .toString() + &quot; &quot; + units[digitGroups]
  }
  </code></pre>
  <p>Here's the result:</p>
  <pre><code>Format file size using Formatter.formatFileSize 1,00 GB, 1,07 GB
  Format file size using readableFileSize 953,7 MB, 1 GB
  </code></pre>
  <p>What is wrong with <code>android.text.format.Formatter.formatFileSize</code>?</p>
  <p><strong>UPDATE</strong></p>
  <p>starting from Oreo Android it uses 1000 instead of 1024 bytes for 1 kb</p>
  <p><a href="https://i.stack.imgur.com/70Tp9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/70Tp9.png" alt="enter image description here" /></a></p>
  <p>we could use <code>Formatter.formatFileSize(this, 1024L, Formatter.FLAG_IEC_UNITS)</code></p>
  <p>but method with third parameter is hidden in source code:</p>
  <pre><code>/** @hide */
  public static String formatFileSize(@Nullable Context context, long sizeBytes, int flags) {
      if (context == null) {
          return &quot;&quot;;
      }
      final BytesResult res = formatBytes(context.getResources(), sizeBytes, flags);
      return bidiWrap(context, context.getString(com.android.internal.R.string.fileSizeSuffix,
              res.value, res.units));
  }
  </code></pre>
  <p>so it seems there is no built-in method to get normally formatted localized file size for newer Android version anymore</p>