Save Bitmap in Android as JPEG in External Storage in a folder

前端 未结 5 1167
日久生厌
日久生厌 2020-12-08 20:33

I am using this code to save Bitmap in External Storage but it does not create the folder if it not exists:

String path = Environment.getExternalStorageDirec         


        
5条回答
  •  鱼传尺愫
    2020-12-08 21:22

    Use the following:

    File dir = new File(path + "/Captures/");
    if(!dir.exists()) {
        dir.mkdirs();
    }
    File file = new File(path + "/Captures/", "screen.jpg");
     ......
    

提交回复
热议问题