0
我刚开始开发一个android应用程序,所以我需要你的帮助。为什么getExternalFilesDir将我的文件保存到内部存储
这是我的代码。
private File createImageFile() throws IOException{
File image = null;
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); //Get Date
String imageFileName = "JPEG_" + timeStamp + "_";
File storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES); //Get the directory of pictures
if (isExertnalStorageWritable()){
if(isExternalStorageReadable()) {
image = File.createTempFile(imageFileName, ".jpg", storageDir); //Create the temp file
mCurrentPhotoPath = image.getAbsolutePath();
}
}
return image;
}
但我的临时文件总是在内部存储器中创建,而不是在外部存储器中创建。
尝试使用Environment.getExternalStorageDirectory()获取设备的基础文件夹,而不是应用程序特定的文件夹 – pantos27