getExternalStoragePublicDirectory对三星Galaxy Note的路径 [英] Path of getExternalStoragePublicDirectory on Samsung Galaxy Note

查看:146
本文介绍了getExternalStoragePublicDirectory对三星Galaxy Note的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序,我创建该存储在设备的下载目录中的文件。我所有的用户都满意这个机制......除了使用三星Galaxy Note的人。

In my app, I am creating files which are stored in the devices Downloads directory. All of my users are happy with this mechanism... except the ones using a Samsung Galaxy Note.

这是一种很难调试不拥有这样的设备。在我的code,我使用

It's kind of hard to debug without owning such a device. Within my code, I am using

File newFile = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS),
            "file01");
    if (newFile.exists()) {
        // show error
    } else {
        if (!newFile.mkdirs()) {
            // show error
        }
    }

要找到目标目录的路径。在Galaxy Note的,返回的路径是/存储/ sdcard0 /下载。然而,在本地文件系统的目录是用小写字母(下载),并通过我的应用程序创建的文件不显然不是在本地文件目录中。至少我的用户抱怨这一点。我认为这个问题与路径小写/大写的差异有关。

to find the path for the target directory. On the Galaxy Note, the path returned is "/storage/sdcard0/Download". However, on the local file system directory is written in lowercase ("download") and the files created by my app do not obviously not exist on the local file directory. At least my users complain about this. I assume the problem to be related with the lowercase/uppercase difference in the path.

没有任何人有一个想法,为什么这个工程上的所有设备,除了Galaxy Note的?

Does anybody have an idea why this works on all devices except the Galaxy Note?

谢谢!

推荐答案

但不保证该位置返回 getExternalStoragePublicDirectory()确实存在。你的可能会需要这些目录中的特定一个的第一应用程序。因此,你的工作就是打电话 mkdirs()在该位置,在所有设备上,而不仅仅是这一个。

There is no guarantee that the location returned by getExternalStoragePublicDirectory() actually exists. Yours may be the first app that needs a particular one of those directories. Hence, it is your job to call mkdirs() on that location, on all devices, not just this one.

除此之外,至于为什么别人(三星或其他第三方应用程序)时创建一个小写的下载目录,只有这样才能确定为什么是找出谁创建的目录,然后联系了开发商。这是不太可能的时间是值得的投资。

Beyond that, as to why somebody else (Samsung or another third-party app) is creating a lowercase download directory, the only way to determine "why" is to figure out who created that directory and then contact that developer. This is unlikely to be a worthwhile investment in time.

只要您正在呼叫 mkdirs()以创建下载,任何其他目录中可能存在不真的是你的关注。如果你想检测可能的碰撞这样的,并警告用户,你可以做到这一点,虽然我不知道,如果这样做是值得的。

So long as you are calling mkdirs() to create Download, whatever other directories that may exist are not really your concern. If you wanted to detect possible collisions like this, and warn the user, you could do that, though I have no idea if that would be worthwhile.

这篇关于getExternalStoragePublicDirectory对三星Galaxy Note的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆