pull/1434/head
gedoor 3 years ago
parent 6180a654ae
commit d80c5f34f7
  1. 7
      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 kotlinx.coroutines.withContext
import splitties.init.appCtx import splitties.init.appCtx
import java.io.File import java.io.File
import java.io.FileOutputStream
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
@ -114,8 +115,10 @@ object Backup {
private fun writeListToJson(list: List<Any>, fileName: String, path: String) { private fun writeListToJson(list: List<Any>, fileName: String, path: String) {
if (list.isNotEmpty()) { if (list.isNotEmpty()) {
val json = GSON.toJson(list) val file = FileUtils.createFileIfNotExist(path + File.separator + fileName)
FileUtils.createFileIfNotExist(path + File.separator + fileName).writeText(json) FileOutputStream(file).use {
GSON.writeToOutputStream(it, list)
}
} }
} }

Loading…
Cancel
Save