备份添加书签

pull/300/head
gedoor 4 years ago
parent 2d58ca970b
commit 7b6ac39e6d
  1. 4
      app/src/main/java/io/legado/app/data/dao/BookmarkDao.kt
  2. 1
      app/src/main/java/io/legado/app/help/storage/Backup.kt
  3. 3
      app/src/main/java/io/legado/app/help/storage/Restore.kt

@ -8,8 +8,8 @@ import io.legado.app.data.entities.Bookmark
@Dao @Dao
interface BookmarkDao { interface BookmarkDao {
@Query("select * from bookmarks") @get:Query("select * from bookmarks")
fun all(): List<Bookmark> val all: List<Bookmark>
@Query("select * from bookmarks where bookUrl = :bookUrl or (bookName = :bookName and bookAuthor = :bookAuthor)") @Query("select * from bookmarks where bookUrl = :bookUrl or (bookName = :bookName and bookAuthor = :bookAuthor)")
fun observeByBook( fun observeByBook(

@ -42,6 +42,7 @@ object Backup {
withContext(IO) { withContext(IO) {
synchronized(this@Backup) { synchronized(this@Backup) {
writeListToJson(App.db.bookDao().all, "bookshelf.json", backupPath) writeListToJson(App.db.bookDao().all, "bookshelf.json", backupPath)
writeListToJson(App.db.bookmarkDao().all, "bookmark.json", backupPath)
writeListToJson(App.db.bookGroupDao().all, "bookGroup.json", backupPath) writeListToJson(App.db.bookGroupDao().all, "bookGroup.json", backupPath)
writeListToJson(App.db.bookSourceDao().all, "bookSource.json", backupPath) writeListToJson(App.db.bookSourceDao().all, "bookSource.json", backupPath)
writeListToJson(App.db.rssSourceDao().all, "rssSource.json", backupPath) writeListToJson(App.db.rssSourceDao().all, "rssSource.json", backupPath)

@ -113,6 +113,9 @@ object Restore {
fileToListT<Book>(path, "bookshelf.json")?.let { fileToListT<Book>(path, "bookshelf.json")?.let {
App.db.bookDao().insert(*it.toTypedArray()) App.db.bookDao().insert(*it.toTypedArray())
} }
fileToListT<Bookmark>(path, "bookmark.json")?.let {
App.db.bookmarkDao().insert(*it.toTypedArray())
}
fileToListT<BookGroup>(path, "bookGroup.json")?.let { fileToListT<BookGroup>(path, "bookGroup.json")?.let {
App.db.bookGroupDao().insert(*it.toTypedArray()) App.db.bookGroupDao().insert(*it.toTypedArray())
} }

Loading…
Cancel
Save