16

我正在保存这样的图片:

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();
}

但是,当我通过 Windows 查找图像时,它在内部存储器中,画廊证实了这一点:

在电脑上

画廊详情

最后一个令人困惑,它说的是内部存储器,但也有sdcard0文件路径。

那么什么时候外部不等于外部呢?它是设备设置的事情,还是我错过使用/错过理解getExternalStoragePublicDirectory

4

1 回答 1

17

MTP 引擎有时会报告getExternalStorageDirectory()为“内部存储”,这就是当您在 Windows、Linux 等设备上将设备挂载为卷时它以该名称显示的原因。

外部存储始终意味着用户可以通过 USB 电缆访问的存储。“内部存储”标签可能用于外部存储是板载(“内部”)闪存的一部分的设备。

于 2013-10-19T12:37:46.130 回答