List of usage examples for android.content ContentResolver delete
public final int delete(@RequiresPermission.Write @NonNull Uri url, @Nullable String where, @Nullable String[] selectionArgs)
From source file:Main.java
private static void deleteFileForMediaStore(Context mContext, File file) { // Match on the file path String selection = MediaStore.Images.Media.DATA + " = ?"; String[] selectionArgs = new String[] { file.getAbsolutePath() }; // Query for the ID of the media matching the file path Uri queryUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; ContentResolver contentResolver = mContext.getContentResolver(); contentResolver.delete(queryUri, selection, selectionArgs); }
From source file:Main.java
public static boolean deleteLogsOfNumber(ContentResolver contentResolver, String numberToDelete) { boolean isSuccess = false; isSuccess = contentResolver.delete(CallLog.Calls.CONTENT_URI, CallLog.Calls.NUMBER + "= ?", new String[] { numberToDelete }) > 0; return isSuccess; }
From source file:com.github.mkjensen.dml.live.SetupFragment.java
private static void deleteExistingChannels(ContentResolver resolver, String inputId) { int deleted = resolver.delete(TvContract.buildChannelsUriForInput(inputId), null, // where null // selectionArgs );/*from w w w .ja va 2 s .c om*/ Log.d(TAG, "Deleted existing channels: " + deleted); }
From source file:org.totschnig.myexpenses.provider.DbUtils.java
private static void cacheEventData() { if (ContextCompat.checkSelfPermission(MyApplication.getInstance(), Manifest.permission.WRITE_CALENDAR) != PackageManager.PERMISSION_GRANTED) { return;/* w ww . j av a 2 s . com*/ } String plannerCalendarId = PrefKey.PLANNER_CALENDAR_ID.getString("-1"); if (plannerCalendarId.equals("-1")) { return; } ContentValues eventValues = new ContentValues(); ContentResolver cr = MyApplication.getInstance().getContentResolver(); //remove old cache cr.delete(TransactionProvider.EVENT_CACHE_URI, null, null); Cursor planCursor = cr.query(Template.CONTENT_URI, new String[] { DatabaseConstants.KEY_PLANID }, DatabaseConstants.KEY_PLANID + " IS NOT null", null, null); if (planCursor != null) { if (planCursor.moveToFirst()) { String[] projection = MyApplication.buildEventProjection(); do { long planId = planCursor.getLong(0); Uri eventUri = ContentUris.withAppendedId(CalendarContractCompat.Events.CONTENT_URI, planId); Cursor eventCursor = cr.query(eventUri, projection, CalendarContractCompat.Events.CALENDAR_ID + " = ?", new String[] { plannerCalendarId }, null); if (eventCursor != null) { if (eventCursor.moveToFirst()) { MyApplication.copyEventData(eventCursor, eventValues); cr.insert(TransactionProvider.EVENT_CACHE_URI, eventValues); } eventCursor.close(); } } while (planCursor.moveToNext()); } planCursor.close(); } }
From source file:com.ksk.droidbatterybooster.provider.PowerSchedule.java
public static boolean deleteSchedule(ContentResolver contentResolver, long scheduleId) { if (scheduleId == OptimalMode.INVALID_ID) return false; int deletedRows = contentResolver.delete(getUri(scheduleId), "", null); return deletedRows == 1; }
From source file:com.marvin.rocklock.PlaylistUtils.java
/** * Deletes the playlist with the given ID * * @param context the managing activity//from w ww . j a va2 s .c o m * @param playlistId the playlist id to delete */ public static void deletePlaylist(RockLockActivity context, int playlistId) { ContentResolver resolver = context.getContentResolver(); // Delete playlist contents Uri uri = MediaStore.Audio.Playlists.Members.getContentUri("external", playlistId); resolver.delete(uri, null, null); // Delete row in playlist database String filter = MediaStore.Audio.Playlists._ID + "=" + playlistId; resolver.delete(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI, filter, null); }
From source file:com.ksk.droidbatterybooster.provider.OptimalMode.java
public static boolean deleteMode(ContentResolver contentResolver, long modeId) { if (modeId == OptimalMode.INVALID_ID) return false; int deletedRows = contentResolver.delete(getContentUriForId(modeId), "", null); return deletedRows == 1; }
From source file:com.nbos.phonebook.sync.platform.ContactManager.java
public static void resetDirtySharedBooks(Context ctx) { ContentResolver cr = ctx.getContentResolver(); int num = cr.delete(Constants.SHARE_BOOK_URI, BookTable.DELETED + " = 1", null); Log.i(tag, "Deleted " + num + " contacts sharing with"); ContentValues values = new ContentValues(); values = new ContentValues(); values.put(BookTable.DIRTY, "0"); num = cr.update(Constants.SHARE_BOOK_URI, values, null, null); Log.i(tag, "Updated " + num + " sharebooks to dirty = 0"); }
From source file:Main.java
public static void removeFromPlaylist(ContentResolver resolver, int audioId, long playlistId) { String[] cols = new String[] { "count(*)" }; Uri uri = MediaStore.Audio.Playlists.Members.getContentUri("external", playlistId); Cursor cur = resolver.query(uri, cols, null, null, null); cur.moveToFirst();//from w ww. j a v a2 s .c o m final int base = cur.getInt(0); cur.close(); ContentValues values = new ContentValues(); resolver.delete(uri, MediaStore.Audio.Playlists.Members.AUDIO_ID + "=" + audioId, null); }
From source file:com.csipsimple.backup.SipProfileJson.java
public static void restoreSipAccounts(Context ctxt, JSONArray accounts) { ContentResolver cr = ctxt.getContentResolver(); // Clear old existing accounts cr.delete(SipProfile.ACCOUNT_URI, "1", null); cr.delete(SipManager.FILTER_URI, "1", null); // Add each accounts for (int i = 0; i < accounts.length(); i++) { try {// w w w . j a va 2s . c om JSONObject account = accounts.getJSONObject(i); restoreSipProfile(account, cr); } catch (JSONException e) { Log.e(THIS_FILE, "Unable to parse item " + i, e); } } }