- Home /
Unable to read XML in Unity 5 Android
I just migrated to Unity 5 (and Oculus Mobile 0.5.0 as well) and I'm facing the following issue only in release mode (i.e. not when the "Development Build" flag is checked) any time I try to read an xml file from the Galaxy Note 4 device storage:
UnauthorizedAccessException: Access to the path "/sdcard/Oculus/Product/Settings.xml" is denied.
Here's the offending code:
FileStream stream = new FileStream(filename, FileMode.Open);
Everything ran fine in previous versions, and still runs fine in the "Development Build". Anyone know why this might be happening?
(Note: It's quite possible that this may be a problem on the Oculus side, but why would only a Release build be throwing this exception??)
Thanks, Saswat
Answer by sapanda88 · Apr 29, 2015 at 02:16 PM
Issue resolved. Looks like using that filestream constructor always opens with ReadWrite permissions. And I guess the release build for Unity 5 is stricter about those permissions? Anyhow, this does the trick:
FileStream stream = new FileStream(filename, FileMode.Open, FileAccess.Read);
Answer by Thomas Train · Apr 30, 2015 at 07:16 AM
your case reminds me of giving a permission to Android manifest file.
check this first.
http://stackoverflow.com/questions/8954293/permission-to-read-data-from-sd-card