How to save image captured with camera in specific folder

前端 未结 1 1439
礼貌的吻别
礼貌的吻别 2020-12-17 04:48

I am trying to save photo and video like

Intent imageIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
String pathMedia = Environment.g         


        
相关标签:
1条回答
  • 2020-12-17 05:17

    It's probably because you never created the folder, try this:

    File imagesFolder = new File(Environment.getExternalStorageDirectory(), "MyImages");
    imagesFolder.mkdirs(); // <----
    File image = new File(imagesFolder, "image_001.jpg");
    Uri uriSavedImage = Uri.fromFile(image);
    imageIntent.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedImage);
    
    0 讨论(0)
提交回复
热议问题