I have a sync adapter for my DB and at certain points in the application usage, it needs to sync the DB now. I would like to trigger the sync adapter as if its sync-time popped and then re-establish the sync time (i.e., 4 hours from this 'sync now" event).
I think (not tested) a better solution is already defined in the ContentResolver.
ContentResolver.requestSync(account, authority, extras);
so one might do the following:
AccountManager am = AccountManager.get(context);
Account account = null;
am.getAccountsByType(mytype);
for(Account a : accounts) {
if (am.getUserData(account, key)) {
account = a;
break;
}
}
Bundle extras = new Bundle();
extras.putString(EXTRA_mystuff, myvalue);
ContentResolver.requestSync(account, authority, extras)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With