0

我在检测 Android 设备中的所有内存路径时遇到问题。如果我们尝试提供提示和示例,我们将无法获得正确的外部存储器路径。

例如 :

如果我们尝试在三星 Tab 2 中获取外部存储器使用的代码::

Environment.getExternalStorageDirectory().getAbsolutePath()

它将为我们提供内部挂载内存路径。//存储/sdcard0/

经过大量谷歌搜索后,我找到了一个显示设备所有路径的应用程序

应用程序名称“ ES Explorer ”此应用程序显示所有内存路径。

请为我们提供任何解决方案,以便我们解决问题

4

3 回答 3

1

Beyond those types of storage volumes specifically supported by the standard Android SDK is a wide variety of vendor- and version- unique possibilities.

You can find all mounted filesystems by reading /proc/mounts as a text file.

However:

  • This will only find filesystems which are actually mounted - for example, it will not find USB storage volumes if they are handled as arbitrary USB accessories by an application, rather than mounted by the Linux operating system underlying Android.

  • You will have to apply some logic to filter out all the other various file systems which are not general storage devices and show up in the list. It used to be that you could detect "external" storage volumes by looking for "vfat" as a type, but that is no longer used in recent Android versions

  • Especially in recent Android versions, the actual path of the mount as discovered from /proc/mounts and the path customarily used may not match, as the customary path may redirect to the actual one by multiple levels of symbolic links

于 2013-05-14T14:42:43.407 回答
0

不幸的是,三星处理存储的方式与其他一些设备略有不同。自从他们的 Android 3.2 版本以来,他们还禁止常规应用程序写入外部存储。话虽如此,您仍然可以读取(访问)外部存储。以下是两个可能的外部存储位置的路径。实际上,我已经专门为 Galaxy Tab 2.0(7 英寸)编程,所以来吧:

插入的 microSD 卡:mnt/extSdCard
通过三星 USB 适配器连接的外部存储:mnt/UsbDriveA
“sdcard”存储(不是插入的 SD 卡):getExternalStorageDirectory()如您所知。

我尝试了多种方法来使用函数来查找路径,但从来没有运气。但是,这行得通,所以我很满意。我希望它也可以帮助你。

于 2013-05-14T15:02:55.130 回答
-1

请尝试使用以下代码。

public static File FileCache(Context context) {
    // Find the dir to save cached images
    File cacheDir;
    if (android.os.Environment.getExternalStorageState().equals(
            android.os.Environment.MEDIA_MOUNTED))
        cacheDir = new File(
                android.os.Environment.getExternalStorageDirectory(),
                "TechTool_Pdf");
    else
        cacheDir = context.getCacheDir();
    if (!cacheDir.exists())
        cacheDir.mkdirs();
    return cacheDir;
}
于 2013-05-14T13:26:02.587 回答