pull/34/head
kunfei 5 years ago
parent 0c05bd5040
commit 3798d8b573
  1. 3
      app/src/main/java/io/legado/app/data/dao/RssSourceDao.kt
  2. 2
      app/src/main/java/io/legado/app/help/FileHelp.kt
  3. 26
      app/src/main/java/io/legado/app/help/storage/Backup.kt

@ -8,6 +8,9 @@ import io.legado.app.data.entities.RssSource
@Dao
interface RssSourceDao {
@get:Query("SELECT * FROM rssSources")
val all: List<RssSource>
@Query("SELECT * FROM rssSources")
fun liveAll(): LiveData<List<RssSource>>

@ -28,8 +28,8 @@ object FileHelp {
file.createNewFile()
}
} catch (e: IOException) {
e.printStackTrace()
}
return file
}
}

@ -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)
}
}
Loading…
Cancel
Save