2017-05-01 51 views
1

我一直在使用SQLite作爲我的android應用程序的存儲解決方案。我希望能夠將同步功能添加到我的某個應用中,Firebase看起來像是一個很好的解決方案,但問題是我需要知道是否要使用Firebase將數據與SQLite數據庫同步,或者Firebase可以工作並完全替代SQLite 。我知道Firebase具有離線持久性,但離線時它可以保存與SQLite一樣多的數據,並且查詢功能強大嗎?Firebase而不是SQLite

+0

根據Firebase脫機功能文檔「默認情況下,先前同步的數據將被緩存10MB」。它聲稱具有智能同步功能。除非您預計數據存儲高於10MB,否則只需使用Firebase即可。請參閱文檔[https://firebase.google.com/docs/database/android/offline-capabilities] – ADimaano

+0

謝謝,我需要一個脫機的第一個解決方案,預計超過10MB,因此Firebase可能不是解決方案: (Realm移動平臺看起來更像我想要的。 –

回答

0

顯然這取決於考慮選項的業務規則。所以不會有這個「正確的」答案。

我們至少有一個團隊成員正在考慮這些方面。下面是我們的解決方案:

  1. 是否所有的交易數據,在本地的SQLite作爲我們並不需要交易是跨設備。

  2. 使用Firebase同步其餘部分。

(1)確保我們不會誤用Firebase的客戶端的非永久性離線可用性。

The docs Even with persistence enabled, transactions are not persisted across app restarts. So you cannot rely on transactions done offline being committed to your Firebase Realtime Database. To provide the best user experience, your app should show that a transaction has not been saved into your Firebase Realtime Database yet, or make sure your app remembers them manually and executes them again after an app restart.

(2)確保我們使用火力地堡的永久下線性質進行同步跨設備非事務性數據連接建立後(重)。

The docsThe Firebase Realtime Database client automatically keeps a queue of all write operations that are performed while your app is offline. When persistence is enabled, this queue is also persisted to disk so all of your writes are available when the user or operating system restarts the app. When the app regains connectivity, all of the operations are sent to the Firebase Realtime Database server.

這種方式,我們實現我們的使用中可以接受的狀態。

「它可以保存與SQLite一樣多的數據,並且查詢功能強大嗎?」如果將強大功能翻譯爲「跨設備的transaction」,則按照Firebase作爲遠程數據庫的定義,否則不。

相關問題