Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You should definitely use <code>ContentProvider</code> and <code>SyncAdapters</code>. You should: </p> <ul> <li>Wrap your database functionality with the <code>ContentProvider</code> interface</li> <li>Setup a <code>SyncService</code> matching the authority of the <code>ContentProvider</code></li> <li>In your <code>SyncAdapter</code> specialization, you will override <code>onPerformSync()</code></li> <li><p>Use <code>SharedPreferences</code> storage to keep track of your sync parameters e.g. lastSync time, etc.</p> <pre><code>final SharedPreferences syncMeta = mContext.getSharedPreferences("sync:" + account.name, 0); long lastSyncTime = syncMeta.getLong(LAST_SYNC, 0); long lastServerSyncTime = syncMeta.getLong(SERVER_LAST_SYNC, 0); </code></pre></li> <li><p>This can easily tell you if its the first sync and you can do the initial handling here</p></li> <li>You will write your algorithm here for sync i.e one way/two way.</li> <li>I find it useful to record timestamps and server database ID in your Android records to help with sync. This can help you with your merge strategy.</li> <li><p>Use the ContentProvider here for DB operations. ContentProviders provide a uniform way of accessing your data from your app as well as sync adapters. They will notify the system of updates so that the framework and schedule sync. They can also be helpful as public interfaces of your data to other apps should you choose to do so.</p></li> <li><p>Also, by using SyncService you are saving battery. The system will use network tickles to kick of sync operations and its best if they are batched together for all apps instead of each app waking up the system</p></li> </ul> <p>Finally,</p> <p>There are two samples you should look at. They pretty much cover everything I explained </p> <ol> <li>JumpNote - <a href="http://code.google.com/p/jumpnote/source/browse/" rel="noreferrer">http://code.google.com/p/jumpnote/source/browse/</a></li> <li>SampleSyncAdapter - <a href="http://developer.android.com/resources/samples/SampleSyncAdapter/index.html" rel="noreferrer">http://developer.android.com/resources/samples/SampleSyncAdapter/index.html</a></li> </ol> <p>Both these apps use Google App Engine for the cloud component. Its easy to get started with, so definitely explore that options.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload