0

I've got simple app, and it works fine on my PC. But on my Android-Testing Device it can not work properly. Something wrong with the paths. For Android I'm using the code to get files I want to read/write from StreamingAssets to 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);
     }
 }

And in logcat I've got error:

UnauthorizedAccessException: Access to the path '/data/data/<my project>/files/' is denied.

Write Access is set to Internal, and if I change it to External and add to AndroidManifest.xml:

 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

I get the same problem.

What am I doing wrong? Please tell me, I haven't sleep for about a week trying to solve this

J.V.N.
  • 11
  • 1
  • 4
  • why am I seeing this ... "Application.dataPath". ***ONLY*** ever use application.persistentDataPath in Unity, ever. http://stackoverflow.com/a/35941579/294884 – Fattie Jun 12 '16 at 15:20
  • Because of "Unity's Documentation / On Android Devices"! - http://docs.unity3d.com/Manual/StreamingAssets.html And if I have to use, like u said, ONLY application.persistentDataPath, how can I copy files from StreamingAssets or Resources folder??? – J.V.N. Jun 13 '16 at 10:57

0 Answers0