Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by LK84 · Aug 13, 2016 at 09:58 AM · android buildapplicationfile-iopersistentdatapathbinaryformatter

Empty Application.persisentDataPath on Android device causing UnauthorizedAccessException

Hey, I ran into the following strange problem. My game, which is working fine on the Editor and Unity remote suddenly started to crash on my Android device in the middle of the game. It actually crashed when I tried to save same User Input on the Application.persistentDataPath. Here is my code:

     static void Save()
     {
         string filename = "/filename.dat";
         BinaryFormatter bf = new BinaryFormatter();
         Debug.Log("path: "+Application.persistentDataPath+filename);
         FileStream file = File.Create(Application.persistentDataPath+filename);
         bf.Serialize(file, UserInputStuff);
         file.Close();
     }

I used Log Viewer fro the asset store to be able to read my Debug Messages on my device. The output from my Debug.Log is "path: /filename.dat". This leads to the UnauthorizedAccessException "Access to the path "/filename.dat" is denied" For some strange reason the persistenddatapath is empty. Weird thing, it used to work before, maybe my Unity update to 5.4 messed it up. The Android OS is 5.0.1 Anyone has an idea?

@UPDATE: Tested it on my girlffriends smartphone. worked fine there. Seems to be a device specific issue. Still worries me. What if I publish the game and user with the same smartphone settings experience the same issues and gonna rate my game badly. How can I make the game "more robust"? Try, catch doesn't really work for me here.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by mouness2020 · Aug 18, 2016 at 12:40 PM

@LK84 I have same problem after updating unity to version 5.4.. problem in some devices like HTC Lenovo Sony ,,, Samsung works fine,, however if you reboot the device then unity can copy files to Application.persisentDataPath and works fine i think its a bug in unity player 5.4 and this cause to me very big problem.. when using sqlite database because sqlite should copy the database file at start to Application.persisentDataPath directory. first time failed to copy then when rebooting the device copy works fine .

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Freaking-Pingo · Aug 21, 2016 at 09:16 PM 0
Share

This did the trick for me as well. I had the exact same issue and this even created a problem for Unity's integrated IAP system. I even created a thread for this issue. This surely smells like a Unity bug. http://forum.unity3d.com/threads/system-unauthorizedaccessexception-access-to-the-path-unity-is-denied.426841/

avatar image LK84 Freaking-Pingo · Aug 24, 2016 at 11:13 AM 0
Share

Can you keep me updated how Unity replies on your bug report?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

54 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to send an Email with the details entered in a json file? 0 Answers

System.IO.File does not contain a definition for 'WriteAllLines' 1 Answer

My app generates a binary file but either fails to save data or load it || Unity for Android 1 Answer

How to "create directories" in specific folders 2 Answers

PersistentDataPath saved files are not writing into android device? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges