title: Androidx EncryptedFile - Best way to write unencrypted File to EncryptedFile
body: <p>I have an unencrypted File that I want to write as an <code>EncryptedFile</code> using the <code>androidx.security</code> library. The example docs show reading the existing file to be encrypted into a byte array then writing that byte array to the encrypted file. I worry if the file that needs to be encrypted is very large reading the bytes into memory could cause OOM crashes on older devices. e.g:</p>
  <pre><code>        val inputStream = FileInputStream(file)
          val bytes = inputStream.readBytes()
          inputStream.close()
          ...
  
          encryptedFile.openFileOutput().apply {
              write(bytes)
              flush()
              close()
          }
  </code></pre>
  <p>Wouldn't opening an input stream and then using the <code>copyTo</code> Kotlin extension be the less memory intensive option? Or is there a better way I am overlooking?</p>
  <pre><code>       encryptedFile.openFileOutput().apply { // opens FileOutputStream
              val inputStream = FileInputStream(file)
              inputStream.copyTo(this)
              inputStream.close()
              flush()
              close()
          }
  </code></pre>