Search code examples
androidunity-game-engineapk

Unity Android's StreamingAssets folder location


I use StreamingAssets for my Android Game, And would like add files in StreamingAssets folder after installation of APK, But I don't know where is the location of this folder.

Can you help me ?


Solution

  • You can not add or modify files that are inside the streaming assets folder after building since on almost all platforms the directory is read only. From the docs:

    On many platforms, the streaming assets folder location is read-only; you can not modify or write new files there at runtime. Use Application.persistentDataPath for a folder location that is writable.

    That said, on Android the filepath to the streaming assets is at "jar:file://" + Application.dataPath + "!/assets, from the same docs:

    Android uses files inside a compressed APK /JAR file, "jar:file://" + Application.dataPath + "!/assets".

    Do note that you can not access this file location through the standard C# File functions, but need to access it using a webrequest.

    If you need a directory to store data during run time you need to use the Application.persistenDataPath instead. From the docs:

    This value is a directory path where you can store data that you want to be kept between runs. When you publish on iOS and Android, persistentDataPath points to a public directory on the device. Files in this location are not erased by app updates. The files can still be erased by users directly.