我有一个简单的应用程序,它在我的电脑上工作正常。但是在我的Android测试设备上,它无法正常工作。路径有问题。对于Android,我使用代码将我想要读取/写入StreamingAssets的文件传递给Application.persistentDataPath:
void Awake(){if (firstWord == "Adroid" || deviceType == "Handheld")
{
StartCoroutine("Downloader");
}
}
IEnumerator Downloader()
{
WWW wwwDD = new WWW("jar:file://" + Application.dataPath + "!/assets/DropDown.xml");
yield return wwwDD;
if (wwwDD.isDone == true)
{
File.WriteAllBytes(Application.persistentDataPath + "/DropDown.xml", wwwDD.bytes);
}
WWW www1st = new WWW("jar:file://" + Application.dataPath + "!/assets/1st.xml");
yield return www1st;
if (www1st.isDone == true)
{
File.WriteAllBytes(Application.persistentDataPath + "/1st.xml", www1st.bytes);
}
WWW wwwDefault = new WWW("jar:file://" + Application.dataPath + "!/assets/Default.xml");
yield return wwwDefault;
if (wwwDefault.isDone == true)
{
File.WriteAllBytes(Application.persistentDataPath + "/Default.xml", wwwDefault.bytes);
}
}
在logcat中我遇到了错误:
UnauthorizedAccessException: Access to the path '/data/data/<my project>/files/' is denied.
Write Access设置为Internal,如果我将其更改为External并添加到AndroidManifest.xml:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
我遇到同样的问题。
我做错了什么?请告诉我,我已经睡了大约一个星期试图解决这个问题