Android
android.content
public abstract class

android.content.TempProviderSyncAdapter

java.lang.Object
android.content.SyncAdapter
android.content.TempProviderSyncAdapter
Nested Classes
TempProviderSyncAdapter.SyncData Used by getServerDiffs() to track the sync progress for a given sync adapter. 

Summary

Constants inherited from class android.content.SyncAdapter

Public Constructors

            TempProviderSyncAdapter(SyncableContentProvider provider)

Public Methods

          void  cancelSync()
Cancel the most recently initiated sync.
    final      Context  getContext()
Retrieve the Context this adapter is running in.
abstract          void  getServerDiffs(SyncContext context, TempProviderSyncAdapter.SyncData syncData, SyncableContentProvider tempProvider, Bundle extras, Object syncInfo, SyncResult syncResult)
Get diffs from the server since the last completed sync and put them into a temporary provider.
abstract          boolean  isReadOnly()
Implement this to return true if the data in your content provider is read only.
          TempProviderSyncAdapter.SyncData  newSyncData()
Create and return a new, empty SyncData object
abstract          void  onAccountsChanged(String[] accounts)
Called when the accounts list possibly changed, to give the SyncAdapter a chance to do any necessary bookkeeping, e.g.
abstract          void  onSyncCanceled()
Indicate to the SyncAdapter that the last sync that was started has been cancelled.
abstract          void  onSyncEnding(SyncContext context, boolean success)
Called right after a sync is completed
abstract          void  onSyncStarting(SyncContext context, String account, boolean forced, SyncResult result)
Called right before a sync is started.
          TempProviderSyncAdapter.SyncData  readSyncData(SyncableContentProvider contentProvider)
Reads the sync data from the ContentProvider
abstract          void  sendClientDiffs(SyncContext context, SyncableContentProvider clientDiffs, SyncableContentProvider serverDiffs, SyncResult syncResult, boolean dontActuallySendDeletes)
Send client diffs to the server, optionally receiving more diffs from the server
    final      void  setContext(Context context)
          void  startSync(SyncContext syncContext, String account, Bundle extras)
Initiate a sync for this account.
          void  writeSyncData(TempProviderSyncAdapter.SyncData syncData, SyncableContentProvider contentProvider)
Stores the sync data in the Sync Stats database, keying it by the account that was set in the last call to onSyncStarting()

Protected Methods

          Object  createSyncInfo()
          boolean  hasTooManyDeletions(SyncStats stats)
          void  initTempProvider(SyncableContentProvider cp)
Initializes the temporary content providers used during sendClientDiffs(SyncContext, SyncableContentProvider, SyncableContentProvider, SyncResult, boolean).
          void  logSyncDetails(long bytesSent, long bytesReceived)
Logs details on the sync.
Methods inherited from class android.content.SyncAdapter
Methods inherited from class java.lang.Object

Details

Public Constructors

public TempProviderSyncAdapter(SyncableContentProvider provider)

Public Methods

public void cancelSync()

Cancel the most recently initiated sync. Due to race conditions, this may arrive after the ISyncContext.onFinished() for that sync was called. IPC invocations of this method and startSync() are guaranteed to be serialized.

public final Context getContext()

Retrieve the Context this adapter is running in. Only available once onSyncStarting() is called (not available from constructor).

public abstract void getServerDiffs(SyncContext context, TempProviderSyncAdapter.SyncData syncData, SyncableContentProvider tempProvider, Bundle extras, Object syncInfo, SyncResult syncResult)

Get diffs from the server since the last completed sync and put them into a temporary provider.

Parameters

context allows you to publish status and interact with the user during interactive syncs.
syncData used to track the progress this client has made in syncing data from the server
tempProvider this is where the diffs should be stored
extras any extra data describing the sync that is desired
syncInfo sync adapter-specific data that is used during a single sync operation
syncResult information to track what happened during this sync attempt

public abstract boolean isReadOnly()

Implement this to return true if the data in your content provider is read only.

public TempProviderSyncAdapter.SyncData newSyncData()

Create and return a new, empty SyncData object

public abstract void onAccountsChanged(String[] accounts)

Called when the accounts list possibly changed, to give the SyncAdapter a chance to do any necessary bookkeeping, e.g. to make sure that any required SubscribedFeeds subscriptions exist.

Parameters

accounts the list of accounts

public abstract void onSyncCanceled()

Indicate to the SyncAdapter that the last sync that was started has been cancelled.

public abstract void onSyncEnding(SyncContext context, boolean success)

Called right after a sync is completed

Parameters

context allows you to publish status and interact with the user during interactive syncs.
success true if the sync suceeded, false if an error occured

public abstract void onSyncStarting(SyncContext context, String account, boolean forced, SyncResult result)

Called right before a sync is started.

Parameters

context allows you to publish status and interact with the
account the account to sync
forced if true then the sync was forced
result information to track what happened during this sync attempt

Returns

  • true, if the sync was successfully started. One reason it can fail to start is if there is no user configured on the device.

public TempProviderSyncAdapter.SyncData readSyncData(SyncableContentProvider contentProvider)

Reads the sync data from the ContentProvider

Parameters

contentProvider the ContentProvider to read from

Returns

  • the SyncData for the provider. This may be null.

public abstract void sendClientDiffs(SyncContext context, SyncableContentProvider clientDiffs, SyncableContentProvider serverDiffs, SyncResult syncResult, boolean dontActuallySendDeletes)

Send client diffs to the server, optionally receiving more diffs from the server

Parameters

context allows you to publish status and interact with the user during interactive syncs.
clientDiffs the diffs from the client
serverDiffs the SyncableContentProvider that should be populated with the entries that were returned in response to an insert/update/delete request to the server
syncResult information to track what happened during this sync attempt

public final void setContext(Context context)

public void startSync(SyncContext syncContext, String account, Bundle extras)

Initiate a sync for this account. SyncAdapter-specific parameters may be specified in extras, which is guaranteed to not be null. IPC invocations of this method and cancelSync() are guaranteed to be serialized.

Parameters

syncContext the ISyncContext used to indicate the progress of the sync. When the sync is finished (successfully or not) ISyncContext.onFinished() must be called.
account the account that should be synced
extras SyncAdapter-specific parameters

public void writeSyncData(TempProviderSyncAdapter.SyncData syncData, SyncableContentProvider contentProvider)

Stores the sync data in the Sync Stats database, keying it by the account that was set in the last call to onSyncStarting()

Protected Methods

protected Object createSyncInfo()

protected boolean hasTooManyDeletions(SyncStats stats)

protected void initTempProvider(SyncableContentProvider cp)

Initializes the temporary content providers used during sendClientDiffs(SyncContext, SyncableContentProvider, SyncableContentProvider, SyncResult, boolean). May copy relevant data from the underlying db into this provider so joins, etc., can work.

Parameters

cp The ContentProvider to initialize.

protected void logSyncDetails(long bytesSent, long bytesReceived)

Logs details on the sync. Normally this will be overridden by a subclass that will provide provider-specific details.

Parameters

bytesSent number of bytes the sync sent over the network
bytesReceived number of bytes the sync received over the network
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:56