diff --git a/app/src/main/java/xyz/fycz/myreader/model/storage/Backup.kt b/app/src/main/java/xyz/fycz/myreader/model/storage/Backup.kt index 8124e9d..c4b5409 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/storage/Backup.kt +++ b/app/src/main/java/xyz/fycz/myreader/model/storage/Backup.kt @@ -62,6 +62,7 @@ object Backup { "readRecord.json", "searchWord.json", "subscribe.json", + "cookie.json", "config.xml" ) } @@ -163,6 +164,13 @@ object Backup { .writeText(json) } } + DbManager.getDaoSession().cookieBeanDao.queryBuilder().list().let { + if (it.isNotEmpty()) { + val json = GSON.toJson(it) + FileUtils.getFile(backupPath + File.separator + "cookie.json") + .writeText(json) + } + } try { val setting = SysManager.getNewSetting() val readStyles = setting.readStyles diff --git a/app/src/main/java/xyz/fycz/myreader/model/storage/Restore.kt b/app/src/main/java/xyz/fycz/myreader/model/storage/Restore.kt index 2ceb814..a80265c 100644 --- a/app/src/main/java/xyz/fycz/myreader/model/storage/Restore.kt +++ b/app/src/main/java/xyz/fycz/myreader/model/storage/Restore.kt @@ -166,6 +166,15 @@ object Restore { } catch (e: Exception) { e.printStackTrace() } + try { + val file = FileUtils.getFile(path + File.separator + "cookie.json") + val json = file.readText() + GSON.fromJsonArray(json)?.let { + DbManager.getInstance().session.cookieBeanDao.insertOrReplaceInTx(it) + } + } catch (e: Exception) { + e.printStackTrace() + } try { val settingFile = FileUtils.getFile(path + File.separator + "setting.json") val settingJson = settingFile.readText()