Java I';I’我想转移一个与我的应用程序相关的新文件夹,并将应用程序中拍摄的照片放在此文件夹中

Java I';I’我想转移一个与我的应用程序相关的新文件夹,并将应用程序中拍摄的照片放在此文件夹中,java,android,xml,Java,Android,Xml,这是创建我的文件夹和图像的功能 String mCurrentPhotoPath; private File createImageFile() throws IOException { // Create an image file name File folder = new File(Environment.getExternalStorageDirectory() + File.separator + "MyFolder"); if (!folder.exi

这是创建我的文件夹和图像的功能

String mCurrentPhotoPath;

private File createImageFile() throws IOException {
    // Create an image file name


    File folder = new File(Environment.getExternalStorageDirectory() + File.separator + "MyFolder");
    if (!folder.exists()) {
        success = folder.mkdir();
    }
    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
    String imageFileName = "Photo" + timeStamp + "_";

    File image = File.createTempFile(
            imageFileName,  /* prefix */
            ".jpg",
            folder/* directory */
    );

    // Save a file: path for use with ACTION_VIEW intents
    mCurrentPhotoPath = image.getAbsolutePath();
    return image;
}
这就是我们要做的

mbtnCamera.setOnClickListener(new View.OnClickListener() {
           @Override
             public void onClick(View v) {
                   try {
                    createImageFile();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                startActivityForResult(intent, 0);
                onActivityResult(0,0,intent);
            }
    });

它创建了一个.jpg文件,但无法读取。拍摄照片时,它也在相机文件夹中,可读,但在我的新文件夹中不可读。有人能解释一下原因吗?

你能先解释一下你想做什么吗?
success=folder.mkdir()。所以您没有检查返回值?糟糕<代码>它创建了一个.jpg文件,但无法读取。您创建了一个空文件。所以尺寸为0。这就是你所说的不可读吗?
拍摄照片时,它也在相机文件夹中
。否。如果您使用该意图,相机应用程序将不会将图像写入文件。
,但在我的新文件夹中无法读取。是的,还有你的空文件。没有人碰它。