How to Copy Image File from Gallery to another folder programmatically in Android

前端 未结 5 1060
北荒
北荒 2020-12-08 08:50

I want to pick image from gallery and copy it in to other folder in SDCard.

Code to Pick Image from Gallery

Intent photoPickerIntent = new Intent(Int         


        
5条回答
  •  感动是毒
    2020-12-08 09:18

    OutputStream out;
                String root = Environment.getExternalStorageDirectory().getAbsolutePath()+"/";
                File createDir = new File(root+"Folder Name"+File.separator);
                if(!createDir.exists()) {
                    createDir.mkdir();
                }
                File file = new File(root + "Folder Name" + File.separator +"Name of File");
                file.createNewFile();
                out = new FileOutputStream(file);                       
    
            out.write(data);
            out.close();
    

    Hope it will help u

提交回复
热议问题