title: Writing to Unity's StreamingAssets folder at runtime, on Android?
body: <p>So...my goal is the following:</p>
  
  <ol>
  <li>Download an .mp4 video with an http request.</li>
  <li>Put it in the StreamingAssets folder in my Android APK, using www.bytes and File.WriteAllBytes().</li>
  <li>Play it on an Android device, using the EasyMovieTexture movie plugin I bought.</li>
  </ol>
  
  <p>However, I'm getting errors when I try to write to the StreamingAssets folder, at the following path:</p>
  
  <pre><code>jar:file:///data/app/com.catlard.testName-1.apk!/assets/ash.mp4
  </code></pre>
  
  <p>This is also the first value of _debugString in the PlaceMovieInStreamingAssets function below. Is it even possible to write to the StreamingAssets folder at runtime on Android? Here is the class I'm using to do this stuff. It stops on the WriteAllBytes call -- I know, because I've put print statements before and after, and that's where it's stopping.</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  using System.IO;
  
  public class StartVideoFromWeb : MonoBehaviour {
  
      public string _movieFileName;
      public string _movieHTTPLocation;
      private string _debugString;
      private MediaPlayerCtrl _control;
      public float _mbFileSize = 16.7f;
      private string _movieLocationOnDevice;
  
      private float _prevProg;
  
      private WWW _movieWWW;
  
      public float _kbSpeed;
      public float _timeBetweenSpeedMeasurements = 1f;
  
      // Use this for initialization
  
      public IEnumerator Start() {
  
         yield return StartCoroutine("LoadMovie");
         PlaceMovieInStreamingAssets(_movieWWW);
         yield return new WaitForSeconds(.5f);
         //PlayMovieInCtrl(_movieHTTPLocation + _movieFileName);
         PlayMovieInCtrl(_movieLocationOnDevice);
  
         yield return 0;
      }
  
      public void PlayMovieInCtrl(string path) {
  
         _control = GetComponent&lt;MediaPlayerCtrl&gt;();
         _debugString = _movieFileName + " was loaded into Ctrl";
         _control.Load(path);
         renderer.material.mainTexture = _control.GetVideoTexture();
         _control.Play();
         _debugString = "Attempted to play movie at " + path  + ".";
  
      }
  
      public void PlaceMovieInStreamingAssets(WWW www) {
  
         _movieLocationOnDevice = "jar:file://" + Application.dataPath + "!/assets/" + _movieFileName;
         //_movieLocationOnDevice =  Application.persistentDataPath + "/" + _movieFileName;
         _debugString = "Failed to write to path: " + _movieLocationOnDevice;
         File.WriteAllBytes(_movieLocationOnDevice, www.bytes);
         _debugString = "Wrote file to StreamingAssets folder.";
      }
  
      public IEnumerator MeasureSpeed() {
         yield return new WaitForSeconds(_timeBetweenSpeedMeasurements);
         float tempMeasure = 0;//((_movieWWW.progress - _prevProg) * (_mbFileSize * 1024f)) * (_timeBetweenSpeedMeasurements /Time.deltaTime);
         _prevProg = _movieWWW.progress;
         if(tempMeasure &gt; 0)
           _kbSpeed = Mathf.RoundToInt(tempMeasure);
         StartCoroutine("MeasureSpeed");
      }
  
      public IEnumerator LoadMovie () {
         string urlString = _movieHTTPLocation + _movieFileName;
         _movieWWW = new WWW(urlString);
         bool isLoaded = false;
         StartCoroutine("MeasureSpeed");
  
         while(!isLoaded &amp;&amp; _movieWWW.error == null) {
  
           _debugString = "Movie " + Mathf.RoundToInt(_movieWWW.progress * 100f).ToString() + "%";
  
           if(_kbSpeed &gt; 0)
            _debugString += " @ " + _kbSpeed.ToString() + "kb/sec";
  
           if(_movieWWW.progress == 1.0)
            isLoaded = true;
           yield return 0;
         }
         StopCoroutine("MeasureSpeed");
  
         if(_movieWWW.error == null)
           _debugString = "Movie loaded with no errors.";
         else
           _debugString = _movieWWW.error.ToString();
  
      }
  
      public void OnGUI() {
         GUI.Label(new Rect(0,0,700,100), _debugString);
         GUI.Label(new Rect(0,30, 400, 100), "Buffered: " + _control.GetCurrentSeekPercent().ToString());
      }
  }
  </code></pre>