Hello, I’m creating a Unity build for Windows & Android platforms that utilizes the StreamingAssets folder. I both read and write into this file, using code spinets such as:
string fileText = File.ReadAllText(Application.streamingAssetsPath + "/dialogue/exampleName.txt", Encoding.UTF8)
File.AppendAllText(Application.streamingAssetsPath + "/dialogue/exampleName.txt", fileData, Encoding.UTF8)
This works fine for Windows, however, when using ‘Android Logcat’ to debug my Android emulator, I can see that this process isn’t working for Android. Below is an example of an error I received:
Error Unity DirectoryNotFoundException: Could not find a part of the path "/jar:file:/data/app/~~cgnOTp1Hnbf79qkniGQQaA==/com.DefaultCompany.Game-Mrx_8jC0_G1ZWPVghbDmhg==/base.apk!/assets/dialogue/exampleName/textFile.txt".
When trying to fix this issue, I saw some advise about using ‘UnityWebRequest’ to change the format of the file path string when accessing the Android StreamingAssets folder, but I’m a little confused about how to go about doing this, in all honesty. If possible, can someone explain how to edit my code in such a way so that the following is accomplished:
string fileText = File.ReadAllText(androidPath(Application.streamingAssetsPath + "/dialogue/exampleName.txt"), Encoding.UTF8)
File.AppendAllText(androidPath(Application.streamingAssetsPath + "/dialogue/exampleName.txt"), fileData, Encoding.UTF8)
private string androidPath(string filePath)
{
// WebRequest code here changes filePath to 'androidPath' proper format
return androidPath
}
If this isn’t possible, can someone instead explain what I am misunderstanding about this process for Android devices? Such as, if reading / writing into StreamingAssets isn’t possible, or if it’s not as simple as changing the format of the file path, or something else? Thank you.