List of usage examples for android.content ContentProviderOperation newDelete
public static Builder newDelete(Uri uri)
From source file:org.linphone.ContactEditorFragment.java
private void deleteExistingContact() { String select = ContactsContract.Data.CONTACT_ID + " = ?"; String[] args = new String[] { contact.getID() }; ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); ops.add(ContentProviderOperation.newDelete(ContactsContract.RawContacts.CONTENT_URI) .withSelection(select, args).build()); try {/*w ww. j a v a 2 s .co m*/ getActivity().getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); ContactsManager.getInstance().removeAllFriends(contact); } catch (Exception e) { Log.w(e.getMessage() + ":" + e.getStackTrace()); } }
From source file:at.bitfire.ical4android.AndroidEvent.java
protected void delete(BatchOperation batch) { // remove event batch.enqueue(ContentProviderOperation.newDelete(eventSyncURI()).build()); // remove exceptions of that event, too (CalendarProvider doesn't do this) batch.enqueue(ContentProviderOperation.newDelete(eventsSyncURI()) .withSelection(Events.ORIGINAL_ID + "=?", new String[] { String.valueOf(id) }).build()); }
From source file:org.voidsink.anewjkuapp.calendar.CalendarUtils.java
private static boolean deleteKusssEvents(Context context, String calId) { if (calId != null) { ContentProviderClient provider = context.getContentResolver() .acquireContentProviderClient(CalendarContractWrapper.Events.CONTENT_URI()); if (provider == null) { return false; }//from w ww.j a v a2 s . c o m try { Uri calUri = CalendarContractWrapper.Events.CONTENT_URI(); Cursor c = loadEvent(provider, calUri, calId); if (c != null) { try { ArrayList<ContentProviderOperation> batch = new ArrayList<>(); long deleteFrom = new Date().getTime() - DateUtils.DAY_IN_MILLIS; while (c.moveToNext()) { long eventDTStart = c.getLong(CalendarUtils.COLUMN_EVENT_DTSTART); if (eventDTStart > deleteFrom) { String eventId = c.getString(COLUMN_EVENT_ID); // Log.d(TAG, "---------"); String eventKusssId = null; // get kusssId from extended properties Cursor c2 = provider.query(CalendarContract.ExtendedProperties.CONTENT_URI, CalendarUtils.EXTENDED_PROPERTIES_PROJECTION, CalendarContract.ExtendedProperties.EVENT_ID + " = ?", new String[] { eventId }, null); if (c2 != null) { while (c2.moveToNext()) { if (c2.getString(1).contains(EXTENDED_PROPERTY_NAME_KUSSS_ID)) { eventKusssId = c2.getString(2); } } c2.close(); } if (TextUtils.isEmpty(eventKusssId)) { eventKusssId = c.getString(COLUMN_EVENT_KUSSS_ID_LEGACY); } if (!TextUtils.isEmpty(eventKusssId)) { if (eventKusssId.startsWith("at-jku-kusss-exam-") || eventKusssId.startsWith("at-jku-kusss-coursedate-")) { Uri deleteUri = calUri.buildUpon().appendPath(eventId).build(); Log.d(TAG, "Scheduling delete: " + deleteUri); batch.add(ContentProviderOperation.newDelete(deleteUri).build()); } } } } if (batch.size() > 0) { Log.d(TAG, "Applying batch update"); provider.applyBatch(batch); Log.d(TAG, "Notify resolver"); } else { Log.w(TAG, "No batch operations found! Do nothing"); } } catch (RemoteException | OperationApplicationException e) { Analytics.sendException(context, e, true); return false; } } } finally { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { provider.close(); } else { provider.release(); } } return false; } return true; }
From source file:nl.privacybarometer.privacyvandaag.service.FetcherService.java
private void mobilizeAllEntries() { ContentResolver cr = getContentResolver(); Cursor cursor = cr.query(TaskColumns.CONTENT_URI, new String[] { TaskColumns._ID, TaskColumns.ENTRY_ID, TaskColumns.NUMBER_ATTEMPT }, TaskColumns.IMG_URL_TO_DL + Constants.DB_IS_NULL, null, null); ArrayList<ContentProviderOperation> operations = new ArrayList<>(); while (cursor != null && cursor.moveToNext()) { long taskId = cursor.getLong(0); long entryId = cursor.getLong(1); int nbAttempt = 0; if (!cursor.isNull(2)) { nbAttempt = cursor.getInt(2); }// w w w. ja va 2 s . c o m boolean success = false; Uri entryUri = EntryColumns.CONTENT_URI(entryId); Cursor entryCursor = cr.query(entryUri, null, null, null, null); if (entryCursor != null && entryCursor.moveToFirst()) { if (entryCursor.isNull(entryCursor.getColumnIndex(EntryColumns.MOBILIZED_HTML))) { // If we didn't already mobilized it int linkPos = entryCursor.getColumnIndex(EntryColumns.LINK); int abstractHtmlPos = entryCursor.getColumnIndex(EntryColumns.ABSTRACT); int feedIdPos = entryCursor.getColumnIndex(EntryColumns.FEED_ID); HttpURLConnection connection = null; try { String link = entryCursor.getString(linkPos); String feedId = entryCursor.getString(feedIdPos); Cursor cursorFeed = cr.query(FeedColumns.CONTENT_URI(feedId), null, null, null, null); cursorFeed.moveToNext(); int cookieNamePosition = cursorFeed.getColumnIndex(FeedColumns.COOKIE_NAME); int cookieValuePosition = cursorFeed.getColumnIndex(FeedColumns.COOKIE_VALUE); String cookieName = cursorFeed.getString(cookieNamePosition); String cookieValue = cursorFeed.getString(cookieValuePosition); cursorFeed.close(); // Take substring from RSS content and use it // to try to find a text indicator for better content extraction String contentIndicator = null; String text = entryCursor.getString(abstractHtmlPos); if (!TextUtils.isEmpty(text)) { text = Html.fromHtml(text).toString(); if (text.length() > 60) { contentIndicator = text.substring(20, 40); } } connection = NetworkUtils.setupConnection(link, cookieName, cookieValue); String mobilizedHtml = ArticleTextExtractor.extractContent(connection.getInputStream(), contentIndicator); if (mobilizedHtml != null) { mobilizedHtml = HtmlUtils.improveHtmlContent(mobilizedHtml, NetworkUtils.getBaseUrl(link)); ContentValues values = new ContentValues(); values.put(EntryColumns.MOBILIZED_HTML, mobilizedHtml); ArrayList<String> imgUrlsToDownload = null; if (NetworkUtils.needDownloadPictures()) { imgUrlsToDownload = HtmlUtils.getImageURLs(mobilizedHtml); } String mainImgUrl; if (imgUrlsToDownload != null) { mainImgUrl = HtmlUtils.getMainImageURL(imgUrlsToDownload); } else { mainImgUrl = HtmlUtils.getMainImageURL(mobilizedHtml); } if (mainImgUrl != null) { values.put(EntryColumns.IMAGE_URL, mainImgUrl); } if (cr.update(entryUri, values, null, null) > 0) { success = true; operations.add(ContentProviderOperation.newDelete(TaskColumns.CONTENT_URI(taskId)) .build()); if (imgUrlsToDownload != null && !imgUrlsToDownload.isEmpty()) { addImagesToDownload(String.valueOf(entryId), imgUrlsToDownload); } } } } catch (Throwable ignored) { if (connection != null) { connection.disconnect(); } } finally { if (connection != null) { connection.disconnect(); } } } else { // We already mobilized it success = true; operations.add(ContentProviderOperation.newDelete(TaskColumns.CONTENT_URI(taskId)).build()); } } if (entryCursor != null) entryCursor.close(); if (!success) { if (nbAttempt + 1 > MAX_TASK_ATTEMPT) { operations.add(ContentProviderOperation.newDelete(TaskColumns.CONTENT_URI(taskId)).build()); } else { ContentValues values = new ContentValues(); values.put(TaskColumns.NUMBER_ATTEMPT, nbAttempt + 1); operations.add(ContentProviderOperation.newUpdate(TaskColumns.CONTENT_URI(taskId)) .withValues(values).build()); } } } if (cursor != null) cursor.close(); if (!operations.isEmpty()) { try { cr.applyBatch(FeedData.AUTHORITY, operations); } catch (Throwable ignored) { } } }
From source file:com.google.android.apps.muzei.gallery.GallerySettingsActivity.java
private void setupMultiSelect() { // Set up toolbar mSelectionToolbar = (Toolbar) findViewById(R.id.selection_toolbar); mSelectionToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override//from w w w . ja v a2s . c o m public void onClick(View view) { mMultiSelectionController.reset(true); } }); mSelectionToolbar.inflateMenu(R.menu.gallery_selection); mSelectionToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { int itemId = item.getItemId(); if (itemId == R.id.action_force_now) { Set<Uri> selection = mMultiSelectionController.getSelection(); if (selection.size() > 0) { startService(new Intent(GallerySettingsActivity.this, GalleryArtSource.class) .setAction(ACTION_PUBLISH_NEXT_GALLERY_ITEM) .putExtra(EXTRA_FORCE_URI, selection.iterator().next())); Toast.makeText(GallerySettingsActivity.this, R.string.gallery_temporary_force_image, Toast.LENGTH_SHORT).show(); } mMultiSelectionController.reset(true); return true; } else if (itemId == R.id.action_remove) { final ArrayList<Uri> removeUris = new ArrayList<>(mMultiSelectionController.getSelection()); runOnHandlerThread(new Runnable() { @Override public void run() { // Update chosen URIs ArrayList<ContentProviderOperation> operations = new ArrayList<>(); for (Uri uri : removeUris) { operations.add( ContentProviderOperation.newDelete(GalleryContract.ChosenPhotos.CONTENT_URI) .withSelection(GalleryContract.ChosenPhotos.COLUMN_NAME_URI + "=?", new String[] { uri.toString() }) .build()); } try { getContentResolver().applyBatch(GalleryContract.AUTHORITY, operations); } catch (RemoteException | OperationApplicationException e) { Log.e(TAG, "Error deleting URIs from the ContentProvider", e); } } }); mMultiSelectionController.reset(true); return true; } return false; } }); // Set up controller mMultiSelectionController.setCallbacks(new MultiSelectionController.Callbacks() { @Override public void onSelectionChanged(boolean restored, boolean fromUser) { tryUpdateSelection(!restored); } }); }
From source file:org.totschnig.myexpenses.model.Account.java
/** * deletes all expenses and updates account according to value of handleDelete * * @param filter if not null only expenses matched by filter will be deleted * @param handleDelete if equals {@link #EXPORT_HANDLE_DELETED_UPDATE_BALANCE} opening balance will * be adjusted to account for the deleted expenses, * if equals {@link #EXPORT_HANDLE_DELETED_CREATE_HELPER} a helper transaction * @param helperComment//from w w w .ja va 2 s .c om */ public void reset(WhereFilter filter, int handleDelete, String helperComment) { ArrayList<ContentProviderOperation> ops = new ArrayList<>(); ContentProviderOperation handleDeleteOperation = null; if (handleDelete == EXPORT_HANDLE_DELETED_UPDATE_BALANCE) { long currentBalance = getFilteredBalance(filter).getAmountMinor(); openingBalance.setAmountMinor(currentBalance); handleDeleteOperation = ContentProviderOperation .newUpdate(CONTENT_URI.buildUpon().appendPath(String.valueOf(getId())).build()) .withValue(KEY_OPENING_BALANCE, currentBalance).build(); } else if (handleDelete == EXPORT_HANDLE_DELETED_CREATE_HELPER) { Transaction helper = new Transaction(this, getTransactionSum(filter)); helper.comment = helperComment; helper.status = STATUS_HELPER; handleDeleteOperation = ContentProviderOperation.newInsert(Transaction.CONTENT_URI) .withValues(helper.buildInitialValues()).build(); } String rowSelect = buildTransactionRowSelect(filter); String[] selectionArgs = new String[] { String.valueOf(getId()) }; if (filter != null && !filter.isEmpty()) { selectionArgs = Utils.joinArrays(selectionArgs, filter.getSelectionArgs(false)); } ops.add(updateTransferPeersForTransactionDelete(rowSelect, selectionArgs)); ops.add(ContentProviderOperation.newDelete(Transaction.CONTENT_URI) .withSelection(KEY_ROWID + " IN (" + rowSelect + ")", selectionArgs).build()); //needs to be last, otherwise helper transaction would be deleted if (handleDeleteOperation != null) ops.add(handleDeleteOperation); try { cr().applyBatch(TransactionProvider.AUTHORITY, ops); } catch (Exception e) { AcraHelper.report(e); e.printStackTrace(); } }
From source file:org.mythtv.service.content.v25.LiveStreamHelperV25.java
private int load(final Context context, final LocationProfile locationProfile, LiveStreamInfo[] liveStreams) throws RemoteException, OperationApplicationException { Log.d(TAG, "load : enter"); if (null == context) { throw new RuntimeException("LiveStreamHelperV25 is not initialized"); }// www. ja v a 2s.c o m DateTime lastModified = new DateTime(DateTimeZone.UTC); int processed = -1; int count = 0; ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); for (LiveStreamInfo liveStream : liveStreams) { ContentValues values = convertLiveStreamInfoToContentValues(locationProfile, liveStream, lastModified, -1, null); String[] projection = new String[] { LiveStreamConstants.TABLE_NAME + "_" + LiveStreamConstants._ID }; String selection = LiveStreamConstants.FIELD_ID + " = ?"; String[] selectionArgs = new String[] { String.valueOf(liveStream.getId()) }; selection = appendLocationHostname(context, locationProfile, selection, LiveStreamConstants.TABLE_NAME); Cursor cursor = context.getContentResolver().query(LiveStreamConstants.CONTENT_URI, projection, selection, selectionArgs, null); if (cursor.moveToFirst()) { Log.v(TAG, "load : updating existing liveStream info"); long id = cursor.getLong(cursor .getColumnIndexOrThrow(LiveStreamConstants.TABLE_NAME + "_" + LiveStreamConstants._ID)); context.getContentResolver().update(ContentUris.withAppendedId(LiveStreamConstants.CONTENT_URI, id), values, null, null); } cursor.close(); count++; if (count > BATCH_COUNT_LIMIT) { Log.i(TAG, "load : applying batch for '" + count + "' transactions, processing programs"); processBatch(context, ops, processed, count); count = 0; } } processBatch(context, ops, processed, count); Log.v(TAG, "load : remove deleted liveStreams"); String deletedSelection = LiveStreamConstants.TABLE_NAME + "." + LiveStreamConstants.FIELD_LAST_MODIFIED + " < ?"; String[] deletedSelectionArgs = new String[] { String.valueOf(lastModified.getMillis()) }; deletedSelection = appendLocationHostname(context, locationProfile, deletedSelection, LiveStreamConstants.TABLE_NAME); ops.add(ContentProviderOperation.newDelete(LiveStreamConstants.CONTENT_URI) .withSelection(deletedSelection, deletedSelectionArgs).withYieldAllowed(true).build()); processBatch(context, ops, processed, count); Intent progressIntent = new Intent(LiveStreamService.ACTION_PROGRESS); context.sendBroadcast(progressIntent); if (countLiveStreamsNotComplete(context, locationProfile) > 0) { Log.d(TAG, "load : further updates are required"); try { Thread.sleep(15000); } catch (InterruptedException e) { Log.e(TAG, "load : error", e); } processed = load(context, locationProfile); } Log.d(TAG, "load : exit"); return processed; }
From source file:org.mythtv.service.content.v26.LiveStreamHelperV26.java
private int load(final Context context, final LocationProfile locationProfile, LiveStreamInfo[] liveStreams) throws RemoteException, OperationApplicationException { Log.d(TAG, "load : enter"); if (null == context) { throw new RuntimeException("LiveStreamHelperV26 is not initialized"); }/*w ww . j a v a 2 s. com*/ DateTime lastModified = new DateTime(DateTimeZone.UTC); int processed = -1; int count = 0; ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); for (LiveStreamInfo liveStream : liveStreams) { ContentValues values = convertLiveStreamInfoToContentValues(locationProfile, liveStream, lastModified, -1, null); String[] projection = new String[] { LiveStreamConstants.TABLE_NAME + "_" + LiveStreamConstants._ID }; String selection = LiveStreamConstants.FIELD_ID + " = ?"; String[] selectionArgs = new String[] { String.valueOf(liveStream.getId()) }; selection = appendLocationHostname(context, locationProfile, selection, LiveStreamConstants.TABLE_NAME); Cursor cursor = context.getContentResolver().query(LiveStreamConstants.CONTENT_URI, projection, selection, selectionArgs, null); if (cursor.moveToFirst()) { Log.v(TAG, "load : updating existing liveStream info"); long id = cursor.getLong(cursor .getColumnIndexOrThrow(LiveStreamConstants.TABLE_NAME + "_" + LiveStreamConstants._ID)); context.getContentResolver().update(ContentUris.withAppendedId(LiveStreamConstants.CONTENT_URI, id), values, null, null); } cursor.close(); count++; if (count > BATCH_COUNT_LIMIT) { Log.i(TAG, "load : applying batch for '" + count + "' transactions, processing programs"); processBatch(context, ops, processed, count); count = 0; } } processBatch(context, ops, processed, count); Log.v(TAG, "load : remove deleted liveStreams"); String deletedSelection = LiveStreamConstants.TABLE_NAME + "." + LiveStreamConstants.FIELD_LAST_MODIFIED + " < ?"; String[] deletedSelectionArgs = new String[] { String.valueOf(lastModified.getMillis()) }; deletedSelection = appendLocationHostname(context, locationProfile, deletedSelection, LiveStreamConstants.TABLE_NAME); ops.add(ContentProviderOperation.newDelete(LiveStreamConstants.CONTENT_URI) .withSelection(deletedSelection, deletedSelectionArgs).withYieldAllowed(true).build()); processBatch(context, ops, processed, count); Intent progressIntent = new Intent(LiveStreamService.ACTION_PROGRESS); context.sendBroadcast(progressIntent); if (countLiveStreamsNotComplete(context, locationProfile) > 0) { Log.d(TAG, "load : further updates are required"); try { Thread.sleep(15000); } catch (InterruptedException e) { Log.e(TAG, "load : error", e); } processed = load(context, locationProfile); } Log.d(TAG, "load : exit"); return processed; }
From source file:org.mythtv.service.content.v27.LiveStreamHelperV27.java
private int load(final Context context, final LocationProfile locationProfile, LiveStreamInfo[] liveStreams) throws RemoteException, OperationApplicationException { Log.d(TAG, "load : enter"); if (null == context) { throw new RuntimeException("LiveStreamHelperV27 is not initialized"); }//from w ww . j a v a 2 s .c o m DateTime lastModified = new DateTime(DateTimeZone.UTC); int processed = -1; int count = 0; ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); for (LiveStreamInfo liveStream : liveStreams) { ContentValues values = convertLiveStreamInfoToContentValues(locationProfile, liveStream, lastModified, -1, null); String[] projection = new String[] { LiveStreamConstants.TABLE_NAME + "_" + LiveStreamConstants._ID }; String selection = LiveStreamConstants.FIELD_ID + " = ?"; String[] selectionArgs = new String[] { String.valueOf(liveStream.getId()) }; selection = appendLocationHostname(context, locationProfile, selection, LiveStreamConstants.TABLE_NAME); Cursor cursor = context.getContentResolver().query(LiveStreamConstants.CONTENT_URI, projection, selection, selectionArgs, null); if (cursor.moveToFirst()) { Log.v(TAG, "save : updating existing liveStream info"); long id = cursor.getLong(cursor .getColumnIndexOrThrow(LiveStreamConstants.TABLE_NAME + "_" + LiveStreamConstants._ID)); context.getContentResolver().update(ContentUris.withAppendedId(LiveStreamConstants.CONTENT_URI, id), values, null, null); } cursor.close(); count++; if (count > BATCH_COUNT_LIMIT) { Log.i(TAG, "load : applying batch for '" + count + "' transactions, processing programs"); processBatch(context, ops, processed, count); count = 0; } } processBatch(context, ops, processed, count); Log.v(TAG, "load : remove deleted liveStreams"); String deletedSelection = LiveStreamConstants.TABLE_NAME + "." + LiveStreamConstants.FIELD_LAST_MODIFIED + " < ?"; String[] deletedSelectionArgs = new String[] { String.valueOf(lastModified.getMillis()) }; deletedSelection = appendLocationHostname(context, locationProfile, deletedSelection, LiveStreamConstants.TABLE_NAME); ops.add(ContentProviderOperation.newDelete(LiveStreamConstants.CONTENT_URI) .withSelection(deletedSelection, deletedSelectionArgs).withYieldAllowed(true).build()); processBatch(context, ops, processed, count); Intent progressIntent = new Intent(LiveStreamService.ACTION_PROGRESS); context.sendBroadcast(progressIntent); if (countLiveStreamsNotComplete(context, locationProfile) > 0) { Log.d(TAG, "load : further updates are required"); try { Thread.sleep(15000); } catch (InterruptedException e) { Log.e(TAG, "load : error", e); } processed = load(context, locationProfile); } Log.d(TAG, "load : exit"); return processed; }
From source file:org.mythtv.service.dvr.v26.RecordedHelperV26.java
private void processProgramGroups(final Context context, final LocationProfile locationProfile, Program[] programs) throws RemoteException, OperationApplicationException { Log.v(TAG, "processProgramGroups : enter"); if (null == context) throw new RuntimeException("RecordedHelperV26 is not initialized"); Map<String, ProgramGroup> programGroups = new TreeMap<String, ProgramGroup>(); for (Program program : programs) { if (null != program.getRecording()) { if (null != program.getRecording().getRecGroup() && !"livetv".equalsIgnoreCase(program.getRecording().getRecGroup()) && !"deleted".equalsIgnoreCase(program.getRecording().getRecGroup())) { String cleaned = ArticleCleaner.clean(program.getTitle()); if (!programGroups.containsKey(cleaned)) { ProgramGroup programGroup = new ProgramGroup(); programGroup.setTitle(program.getTitle()); programGroup.setCategory(program.getCategory()); programGroup.setInetref(program.getInetref()); programGroup.setSort(0); programGroups.put(cleaned, programGroup); }/* w w w. j av a 2 s . com*/ } } } int processed = -1; int count = 0; ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); Log.v(TAG, "processProgramGroups : adding 'All' program group in programGroups"); ProgramGroup all = new ProgramGroup(null, "All", "All", "All", "", 1); programGroups.put(all.getProgramGroup(), all); String[] programGroupProjection = new String[] { ProgramGroupConstants._ID }; String programGroupSelection = ProgramGroupConstants.FIELD_PROGRAM_GROUP + " = ?"; programGroupSelection = appendLocationHostname(context, locationProfile, programGroupSelection, null); for (String key : programGroups.keySet()) { Log.v(TAG, "processProgramGroups : processing programGroup '" + key + "'"); ProgramGroup programGroup = programGroups.get(key); ContentValues programValues = convertProgramGroupToContentValues(locationProfile, programGroup); Cursor programGroupCursor = context.getContentResolver().query(ProgramGroupConstants.CONTENT_URI, programGroupProjection, programGroupSelection, new String[] { key }, null); if (programGroupCursor.moveToFirst()) { Long id = programGroupCursor .getLong(programGroupCursor.getColumnIndexOrThrow(ProgramGroupConstants._ID)); ops.add(ContentProviderOperation .newUpdate(ContentUris.withAppendedId(ProgramGroupConstants.CONTENT_URI, id)) .withValues(programValues).withYieldAllowed(true).build()); } else { ops.add(ContentProviderOperation.newInsert(ProgramGroupConstants.CONTENT_URI) .withValues(programValues).withYieldAllowed(true).build()); } programGroupCursor.close(); count++; if (count > 100) { Log.v(TAG, "processProgramGroups : applying batch for '" + count + "' transactions"); processBatch(context, ops, processed, count); } } if (!ops.isEmpty()) { Log.v(TAG, "processProgramGroups : applying batch for '" + count + "' transactions"); processBatch(context, ops, processed, count); } Log.v(TAG, "processProgramGroups : remove deleted program groups"); ops = new ArrayList<ContentProviderOperation>(); DateTime lastModified = new DateTime(); lastModified = lastModified.minusHours(1); String deleteProgramGroupSelection = ProgramGroupConstants.FIELD_LAST_MODIFIED_DATE + " < ?"; String[] deleteProgramGroupArgs = new String[] { String.valueOf(lastModified.getMillis()) }; deleteProgramGroupSelection = appendLocationHostname(context, locationProfile, deleteProgramGroupSelection, ProgramGroupConstants.TABLE_NAME); ops.add(ContentProviderOperation.newDelete(ProgramGroupConstants.CONTENT_URI) .withSelection(deleteProgramGroupSelection, deleteProgramGroupArgs).withYieldAllowed(true).build()); if (!ops.isEmpty()) { Log.v(TAG, "processProgramGroups : applying batch for '" + count + "' transactions"); processBatch(context, ops, processed, count); } Log.v(TAG, "processProgramGroups : exit"); }