List of usage examples for android.content ContentResolver startSync
@Deprecated public void startSync(Uri uri, Bundle extras)
From source file:com.android.providers.contacts.ContactsSyncAdapter.java
public static void updateSubscribedFeeds(ContentResolver cr, String account) { Set<String> feedsToSync = Sets.newHashSet(); feedsToSync.add(getGroupsFeedForAccount(account)); addContactsFeedsToSync(cr, account, feedsToSync); Cursor c = SubscribedFeeds.Feeds.query(cr, sSubscriptionProjection, SubscribedFeeds.Feeds.AUTHORITY + "=? AND " + SubscribedFeeds.Feeds._SYNC_ACCOUNT + "=?", new String[] { Contacts.AUTHORITY, account }, null); try {//from w w w .j av a 2 s . com if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "scanning over subscriptions with authority " + Contacts.AUTHORITY + " and account " + account); } c.moveToNext(); while (!c.isAfterLast()) { String feedInCursor = c.getString(1); if (feedsToSync.contains(feedInCursor)) { feedsToSync.remove(feedInCursor); c.moveToNext(); } else { c.deleteRow(); } } c.commitUpdates(); } finally { c.close(); } // any feeds remaining in feedsToSync need a subscription for (String feed : feedsToSync) { SubscribedFeeds.addFeed(cr, feed, account, Contacts.AUTHORITY, ContactsClient.SERVICE); // request a sync of this feed Bundle extras = new Bundle(); extras.putString(ContentResolver.SYNC_EXTRAS_ACCOUNT, account); extras.putString("feed", feed); cr.startSync(Contacts.CONTENT_URI, extras); } }