diff --git a/app/src/main/java/io/legado/app/data/dao/RssSourceDao.kt b/app/src/main/java/io/legado/app/data/dao/RssSourceDao.kt index cb4d695ab..0d3e6e575 100644 --- a/app/src/main/java/io/legado/app/data/dao/RssSourceDao.kt +++ b/app/src/main/java/io/legado/app/data/dao/RssSourceDao.kt @@ -8,6 +8,9 @@ import io.legado.app.data.entities.RssSource @Dao interface RssSourceDao { + @get:Query("SELECT * FROM rssSources") + val all: List + @Query("SELECT * FROM rssSources") fun liveAll(): LiveData> diff --git a/app/src/main/java/io/legado/app/help/FileHelp.kt b/app/src/main/java/io/legado/app/help/FileHelp.kt index 123f31172..f274c84e4 100644 --- a/app/src/main/java/io/legado/app/help/FileHelp.kt +++ b/app/src/main/java/io/legado/app/help/FileHelp.kt @@ -28,8 +28,8 @@ object FileHelp { file.createNewFile() } } catch (e: IOException) { + e.printStackTrace() } - return file } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/help/storage/Backup.kt b/app/src/main/java/io/legado/app/help/storage/Backup.kt index 1cb43a8db..90a07e0b7 100644 --- a/app/src/main/java/io/legado/app/help/storage/Backup.kt +++ b/app/src/main/java/io/legado/app/help/storage/Backup.kt @@ -1,7 +1,9 @@ package io.legado.app.help.storage import io.legado.app.App +import io.legado.app.help.FileHelp import io.legado.app.utils.GSON +import java.io.File object Backup { @@ -13,9 +15,27 @@ object Backup { } - private fun backupBookshelf() { - val books = App.db.bookDao().allBooks - val json = GSON.toJson(books) + private fun backupBookshelf(path: String) { + val json = GSON.toJson(App.db.bookDao().allBooks) + 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) } } \ No newline at end of file