Android MediaStore insertVideo

后端 未结 5 685
予麋鹿
予麋鹿 2020-11-30 09:46

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

5条回答
  •  独厮守ぢ
    2020-11-30 10:00

    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)
    

提交回复
热议问题