Environment.getExternalStoragePublicDirectory给内部存储Environment、getExternalStoragePublicDirectory

由网友(﹎弍緉眯揂)分享简介:我保存照片,像这样:File dcimDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM);File picsDir = new File(dcimDir, "MyPics");picsDir.mkdirs(...

我保存照片,像这样:

File dcimDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM);
File picsDir = new File(dcimDir, "MyPics");
picsDir.mkdirs(); //make if not exist
File newFile = new File(picsDir, "image.png"));
OutputStream os;
try {
    os = new FileOutputStream(newFile);

    target.compress(CompressFormat.PNG, 100, os);

    os.flush();
    os.close();
    b.recycle();
} catch (FileNotFoundException e) {
    e.printStackTrace();
} catch (IOException e) {
    e.printStackTrace();
}

然而,当我通过它在内部存储器窗口查找图像,画廊证实了这一点:

However, when I look for the image through windows it is in the internal memory, the gallery confirms this:

这最后一个是混乱的,它说,内部存储器,但后来也有 sdcard0 中的文件路径。

This last one is confusing, it says internal memory, but then also has sdcard0 in file path.

所以,当不对外并不意味着外部?它是一个设备设置的事,或/小姐认识 getExternalStoragePublicDirectory

So when does external not mean external? Is it a device set up thing, or an I miss-using/miss-understanding getExternalStoragePublicDirectory?

推荐答案

在MTP发动机有时会报告 getExternalStorageDirectory()为内部存储,这就是为什么它显示出来这个名字,当你安装设备作为Windows,Linux等的体积。

The MTP engine sometimes reports getExternalStorageDirectory() as "Internal Storage", which is why it shows up under that name when you mount the device as a volume on Windows, Linux, etc.

外部存储始终意味着用户可以通过USB电缆的装置访问存储。在内部存储的标签可能是用在哪里外部存储板上(内部)闪存组成部分的设备。

External storage has always meant the storage that the user can access by means of a USB cable. The "Internal Storage" label is probably used on devices where external storage is part of the on-board ("internal") flash.

阅读全文

相关推荐

最新文章