title: Saving Bitmap to External Storage in Android API 28 Result in 0 B file
body: <p>I'm trying to save a bitmap to external storage. I have used the code that I have found in <a href="https://stackoverflow.com/questions/8560501/android-save-image-into-gallery">android - save image into gallery</a>. However, the resulting file is 0 B in size but do contain thumbnail. My code is:
  </p>
  
  <pre><code>private fun saveBitmap(bitmap: Bitmap, name: String) {
      val contentValues = contentValuesOf(
          MediaStore.MediaColumns.TITLE to name,
          MediaStore.MediaColumns.DISPLAY_NAME to name,
          MediaStore.MediaColumns.MIME_TYPE to "images/jpeg",
          MediaStore.MediaColumns.DATE_ADDED to System.currentTimeMillis()
      )
  
      val resolver = contentResolver
      val uri = resolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues)
      val outputStream = resolver.openOutputStream(uri!!)!!
      bitmap.compress(Bitmap.CompressFormat.JPEG, 80, outputStream)
      outputStream.flush()
      outputStream.close()
  }
  </code></pre>