public static interface Dataset.SyncCallback
Dataset.synchronize(SyncCallback).| Modifier and Type | Method and Description |
|---|---|
boolean |
onConflict(Dataset dataset,
List<SyncConflict> conflicts)
This can be triggered during two phases.
|
boolean |
onDatasetDeleted(Dataset dataset,
String datasetName)
This is triggered when the given dataset is deleted remotely.
|
boolean |
onDatasetsMerged(Dataset dataset,
List<String> datasetNames)
If two or more datasets are merged as a result of identity merge,
this will be triggered.
|
void |
onFailure(DataStorageException dse)
This is called when an exception occurs during sync.
|
void |
onSuccess(Dataset dataset,
List<Record> updatedRecords)
This is called after remote changes are downloaded to local storage
and local changes are uploaded to remote storage.
|
void onSuccess(Dataset dataset, List<Record> updatedRecords)
onConflict(com.amazonaws.mobileconnectors.cognito.Dataset, java.util.List<com.amazonaws.mobileconnectors.cognito.SyncConflict>) after
several retries, then updatedRecords will be what are pulled down
from remote in the last retry.dataset - the dataset that performed syncupdatedRecords - new records from remote storage that are
downloadedboolean onConflict(Dataset dataset, List<SyncConflict> conflicts)
List<Record> resolved = new ArrayList<Record>();
for (SyncConflict conflict : conflicts) {
resolved.add(conflicts.resolveWithRemoteRecord());
}
dataset.save(resolved);
return true; // so that synchronize() can retry
If you prefer to add additional logic when resolving conflict, you
can use SyncConflict.resolveWithValue(String)
int remoteMoney = Integer.valueOf(conflicts.getRemote().getValue()); int localMoney = Integer.valueOf(conflicts.getLocal().getValue()); int total = remoteMoney + localMoney; Record resolve = conflicts.resolveWithValue(String.valueOf(total));
dataset - the dataset that performed syncconflicts - conflicting recordsboolean onDatasetDeleted(Dataset dataset, String datasetName)
dataset - dataset handlerdatasetName - the name of the dataset that is deleted remotelyboolean onDatasetsMerged(Dataset dataset, List<String> datasetNames)
dataset - dataset handlerdatasetNames - a list of names of merged datasets'void onFailure(DataStorageException dse)
dse - exceptionCopyright © 2010 Amazon Web Services, Inc. All Rights Reserved.