Android MediaStore insertVideo

Robert picture Robert · Jan 22, 2010 · Viewed 16.3k times · Source

So our app has the option to take either a picture or a video. If the user takes a picture, we can use the MediaStore.Images.Media.insertImage function to add the new image (via a filepath) to the phone's gallery and generate a content:// style URI. Is there a similar process for a captured video, given that we only have it's filepath?

Answer

Pascal picture Pascal · Feb 13, 2013

Here is an easy 'single file based solution':

Whenever you add a file, let MediaStore Content Provider knows about it using

sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(imageAdded)));

Main advantage: work with any mime type supported by MediaStore

Whenever you delete a file, let MediaStore Content Provider knows about it using

getContentResolver().delete(uri, null, null)