add backup&restore cookie feature

pull/22/head
fengyue 3 years ago
parent bf1fd28ad3
commit 509068e589
  1. 8
      app/src/main/java/xyz/fycz/myreader/model/storage/Backup.kt
  2. 9
      app/src/main/java/xyz/fycz/myreader/model/storage/Restore.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

@ -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<CookieBean>(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()

Loading…
Cancel
Save