diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/database/ChatArchiveView.kt b/apps/android/app/src/main/java/chat/simplex/app/views/database/ChatArchiveView.kt index 759177605c..cc92ee75ec 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/database/ChatArchiveView.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/database/ChatArchiveView.kt @@ -94,8 +94,7 @@ private fun rememberSaveArchiveLauncher(cxt: Context, chatArchivePath: String): val contentResolver = cxt.contentResolver contentResolver.openOutputStream(destination)?.let { stream -> val outputStream = BufferedOutputStream(stream) - val file = File(chatArchivePath) - outputStream.write(file.readBytes()) + File(chatArchivePath).inputStream().use { it.copyTo(outputStream) } outputStream.close() Toast.makeText(cxt, generalGetString(R.string.file_saved), Toast.LENGTH_SHORT).show() } diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/database/DatabaseView.kt b/apps/android/app/src/main/java/chat/simplex/app/views/database/DatabaseView.kt index ae0882b53d..df93727123 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/database/DatabaseView.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/database/DatabaseView.kt @@ -489,8 +489,7 @@ private fun rememberSaveArchiveLauncher(cxt: Context, chatArchiveFile: MutableSt val contentResolver = cxt.contentResolver contentResolver.openOutputStream(destination)?.let { stream -> val outputStream = BufferedOutputStream(stream) - val file = File(filePath) - outputStream.write(file.readBytes()) + File(filePath).inputStream().use { it.copyTo(outputStream) } outputStream.close() Toast.makeText(cxt, generalGetString(R.string.file_saved), Toast.LENGTH_SHORT).show() } diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/helpers/Share.kt b/apps/android/app/src/main/java/chat/simplex/app/views/helpers/Share.kt index 2b46110d58..43e5d264bd 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/helpers/Share.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/helpers/Share.kt @@ -40,8 +40,7 @@ fun rememberSaveFileLauncher(cxt: Context, ciFile: CIFile?): ManagedActivityResu val contentResolver = cxt.contentResolver contentResolver.openOutputStream(destination)?.let { stream -> val outputStream = BufferedOutputStream(stream) - val file = File(filePath) - outputStream.write(file.readBytes()) + File(filePath).inputStream().use { it.copyTo(outputStream) } outputStream.close() Toast.makeText(cxt, generalGetString(R.string.file_saved), Toast.LENGTH_SHORT).show() } @@ -74,8 +73,7 @@ fun saveImage(cxt: Context, ciFile: CIFile?) { uri?.let { cxt.contentResolver.openOutputStream(uri)?.let { stream -> val outputStream = BufferedOutputStream(stream) - val file = File(filePath) - outputStream.write(file.readBytes()) + File(filePath).inputStream().use { it.copyTo(outputStream) } outputStream.close() Toast.makeText(cxt, generalGetString(R.string.image_saved), Toast.LENGTH_SHORT).show() }