Android 동기화 SQLite.
-
09-12-2019 - |
문제
SQLite
를 사용하는 사전 종류의 앱을 만들고 있습니다. 나는 외국어와 번역 한 켤레를 유지하는 단일 테이블이 있습니다. Google 문서 도구 에서 특정 스프레드 시트가있는 sync 이 테이블을 원합니다.
이 멋진 라이브러리 GoogleSpreadsheets
를 검색하고 조작 할 수 있습니다. 그래서 적어도 나는 그것을 위해 덮여있다. 그러나 나는 동기화에 대해 편안함을 느끼지 않습니다. 지금,
-
SyncAdapter
를 사용하여 내SQLite
와GoogleSpreadsheet
간에이 동기화를 수행 할 수 있습니까? 그렇다면 어떻게해야합니까?onPerformSync
또는 SMTH에서 스프레드 시트의 행을 검색하고 조작 할 수 있습니까? - 그러한 시나리오의 다른 대안은 무엇이 될 수 있습니까? 사용자가 요청할 때 (예를 들어, 주요 활동) 를 요청할 때 확인을 수행하기 위해 정상적인 서비스를 사용할 수 있습니까?
Google I / O Vids (특히 Android REST Client Apps) )
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.