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 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<Any>, 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)
}
}
}

Loading…
Cancel
Save