private void informMediaScanner(ContentValues map) throws IOException { final File videoFile = fileFromResourceMap(map); String dir = (String) map.get(Resources.DIRECTORY); if (VizUtils.isPublicDir(dir)) { Thread t = new Thread("AddVideoToGallery") { @Override public void run() { VizUtils.informMediaScanner(videoFile.toString()); } }; Utils.threadStart(t, "Failed to add video to gallery"); } }
private void deleteResourceSideEffect(Uri resourceUri) { Log.v("deleteResourceSideEffect(uri=" + resourceUri + ")"); // delete download row correspondong to this content Cursor cursor = query( resourceUri, new String[] { Resources._ID, Resources.DOWNLOAD_ID, Resources.DIRECTORY, Resources.FILENAME, Resources.CONTENT }, null, null, null); if (!cursor.moveToFirst()) { Log.e("deleteResourceSideEffect: cursor empty error"); return; } String downloadId = cursor.getString(cursor.getColumnIndex(Resources.DOWNLOAD_ID)); Uri downloadUri = Downloads.buildDownloadUri(downloadId); delete(downloadUri, null, null); getContext().getContentResolver().notifyChange(downloadUri, null); // delete video file associated with resource String filename = cursor.getString(cursor.getColumnIndex(Resources.FILENAME)); String dir = cursor.getString(cursor.getColumnIndex(Resources.DIRECTORY)); deleteVideo(directorySwitch(dir), filename); if (VizUtils.isPublicDir(dir)) { removeFromMediaStore(VizUtils.getPublicVideoFilename(filename)); } deleteThumbnail(VizContract.PATH_THUMBNAILS, filename + THUMBNAIL_EXT); cursor.close(); }