Unity获取安卓sd外部目录路径

比较取巧的做法,不使用任何Native代码.

public static string GetAndroidInternalFilesDir()
{
    string[] potentialDirectories = new string[]
    {
        "/storage",
        "/sdcard",
        "/storage/emulated/0",
        "/mnt/sdcard",
        "/storage/sdcard0",
        "/storage/sdcard1"
    };

    if(Application.platform == RuntimePlatform.Android)
    {
        for(int i = 0; i < potentialDirectories.Length; i++)
        {
            if(Directory.Exists(potentialDirectories[i]))
            {
                return potentialDirectories[i];
            }
        }
    }
    return "";
}

你可能感兴趣的:(项目的那些JJYY,c#,Unity)