Android Sync SQLite.
-
09-12-2019 - |
質問
SQLite
を使用するアプリの種類を辞書にしています。私は外国語のペアとその翻訳を保つ単一のテーブルを持っています。 sync このテーブルを Google Docs の特定のスプレッドシートを使用してしたい。
私はこの GoogleSpreadsheets
を取得および操作するためのawesomeライブラリそれで、少なくとも私はそれのために覆われています。しかし、私は同期について快適に感じていません。今、
-
SyncAdapter
とSQLite
との間のこの同期を実行するには、GoogleSpreadsheet
を使用できますか?もしそうなら、どうしてそれについて行くのでしょうか。onPerformSync
またはSMTHのスプレッドシートの行を取得して操作しますか? - そのようなシナリオのための他の選択肢が何であるか?ユーザーがそれを要求したときに(メインアクティビティ)の場合は、通常のサービスを使用するように通常のサービスを使用する必要がありますか?
Google I / O VID( Android Restクライアントアプリ)
SyncAdapter
を使用するためにかなり説得するようですが、実際の休息サービスなしで私を助けることができるかどうかわからない。事前にありがとう..
解決
One good reason to use the Android SyncAdapter
, ContentProvider
and SyncManager
is that you will benefit from the Google system knowledge that is useful for preserving battery life and other resources. Some of this content is in the video you link to. For example, exponential back-off logic to prevent wasteful attempts at synchronizing.
There is some good info about battery life preservation by conserving cell radio power in today's Google I/O 2012 talk "Making Good Apps Great: More Advanced Topics for Expert Android Developers." While not mentioned explicitly, I think that the SyncManager
is likely to have the battery conserving properties that are mentioned in this video.
Based on my reading (not actually implementing anything) of the APIs and other resources such as the com.example.android.samplesync
package, it seems that the pattern is flexible enough to adapt to your program needs.
The team I'm working with has implemented custom sync for our android app but I can tell you we didn't consider this option because we were committed to writing as much logic as possible to run with the WebView
. I wouldn't necessarily recommend that, but that's beyond the scope here.