From d80c5f34f727a85cd34fb2c88c677fb6b6c5ae40 Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 19 Nov 2021 22:20:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/storage/Backup.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/storage/Backup.kt b/app/src/main/java/io/legado/app/help/storage/Backup.kt index 85e7b23b6..8e28e0865 100644 --- a/app/src/main/java/io/legado/app/help/storage/Backup.kt +++ b/app/src/main/java/io/legado/app/help/storage/Backup.kt @@ -16,6 +16,7 @@ import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.withContext import splitties.init.appCtx import java.io.File +import java.io.FileOutputStream import java.util.concurrent.TimeUnit @@ -114,8 +115,10 @@ object Backup { private fun writeListToJson(list: List, fileName: String, path: String) { if (list.isNotEmpty()) { - val json = GSON.toJson(list) - FileUtils.createFileIfNotExist(path + File.separator + fileName).writeText(json) + val file = FileUtils.createFileIfNotExist(path + File.separator + fileName) + FileOutputStream(file).use { + GSON.writeToOutputStream(it, list) + } } }