Skip to content

Commit

Permalink
Use std method for buffered writing
Browse files Browse the repository at this point in the history
  • Loading branch information
Semper-Viventem committed Aug 2, 2024
1 parent 3ad1645 commit 4551028
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,9 @@ abstract class AppDatabase : RoomDatabase() {
}
context.contentResolver.openOutputStream(toUri)?.use { outputStream ->
dbFile.inputStream().use { inputStream ->
val buffer = ByteArray(1024)
var bytesRead: Int
while ((inputStream.read(buffer).also { bytesRead = it }) != -1) {
outputStream.write(buffer, 0, bytesRead)
}
inputStream.copyTo(outputStream)
}
}
} ?: throw RuntimeException("Cannot create a backup file stream")
}
}

Expand Down

0 comments on commit 4551028

Please sign in to comment.