|
|
@ -1,7 +1,9 @@ |
|
|
|
package io.legado.app.help.storage |
|
|
|
package io.legado.app.help.storage |
|
|
|
|
|
|
|
|
|
|
|
import io.legado.app.App |
|
|
|
import io.legado.app.App |
|
|
|
|
|
|
|
import io.legado.app.help.FileHelp |
|
|
|
import io.legado.app.utils.GSON |
|
|
|
import io.legado.app.utils.GSON |
|
|
|
|
|
|
|
import java.io.File |
|
|
|
|
|
|
|
|
|
|
|
object Backup { |
|
|
|
object Backup { |
|
|
|
|
|
|
|
|
|
|
@ -13,9 +15,27 @@ object Backup { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun backupBookshelf() { |
|
|
|
private fun backupBookshelf(path: String) { |
|
|
|
val books = App.db.bookDao().allBooks |
|
|
|
val json = GSON.toJson(App.db.bookDao().allBooks) |
|
|
|
val json = GSON.toJson(books) |
|
|
|
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) |
|
|
|
|
|
|
|
val file = FileHelp.getFile(path + File.separator + "bookSource.json") |
|
|
|
|
|
|
|
file.writeText(json) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun backupCssSource(path: String) { |
|
|
|
|
|
|
|
val json = GSON.toJson(App.db.rssSourceDao().all) |
|
|
|
|
|
|
|
val file = FileHelp.getFile(path + File.separator + "cssSource.json") |
|
|
|
|
|
|
|
file.writeText(json) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun backupReplaceRule(path: String) { |
|
|
|
|
|
|
|
val json = GSON.toJson(App.db.replaceRuleDao().all) |
|
|
|
|
|
|
|
val file = FileHelp.getFile(path + File.separator + "replaceRule.json") |
|
|
|
|
|
|
|
file.writeText(json) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |