pull/36/head
kunfei 5 years ago
parent 1188b7089d
commit 95b7631048
  1. 24
      app/src/main/java/io/legado/app/help/storage/Backup.kt

@ -45,28 +45,44 @@ object Backup {
}
private fun backupBookshelf(path: String) {
val json = GSON.toJson(App.db.bookDao().allBooks)
App.db.bookDao().allBooks.let {
if (it.isNotEmpty()) {
val json = GSON.toJson(it)
val file = FileHelp.getFile(path + File.separator + "bookshelf.json")
file.writeText(json)
}
}
}
private fun backupBookSource(path: String) {
val json = GSON.toJson(App.db.bookSourceDao().all)
App.db.bookSourceDao().all.let {
if (it.isNotEmpty()) {
val json = GSON.toJson(it)
val file = FileHelp.getFile(path + File.separator + "bookSource.json")
file.writeText(json)
}
}
}
private fun backupRssSource(path: String) {
val json = GSON.toJson(App.db.rssSourceDao().all)
App.db.rssSourceDao().all.let {
if (it.isNotEmpty()) {
val json = GSON.toJson(it)
val file = FileHelp.getFile(path + File.separator + "rssSource.json")
file.writeText(json)
}
}
}
private fun backupReplaceRule(path: String) {
val json = GSON.toJson(App.db.replaceRuleDao().all)
App.db.replaceRuleDao().all.let {
if (it.isNotEmpty()) {
val json = GSON.toJson(it)
val file = FileHelp.getFile(path + File.separator + "replaceRule.json")
file.writeText(json)
}
}
}
private fun backupPreference(path: String) {
Preferences.getSharedPreferences(App.INSTANCE, path, "config")?.let { sp ->

Loading…
Cancel
Save