UnauthorizedAccessException

Easy Save 2 has been replaced by Easy Save 3, so is no longer supported.
Locked
leo414
Posts: 5
Joined: Thu Dec 08, 2016 3:20 am

UnauthorizedAccessException

Post by leo414 »

Hi!
I got an exception in our crashReport system.
UnauthorizedAccessException
Access to the path "/storage/emulated/0/Android/data/com.tencent.xgame/files/systemData" is denied.
1 ES2FileUtility.CreateFileStream (System.String path, ES2FileMode filemode, Int32 bufferSize)
2 ES2FileStream.CreateStorageStream ()
3 ES2FileStream.Store ()
4 ES2.Save [T] (.T param, System.String identifier)
5 SelectGameViewWnd.OnClickBtnOK ()
6 UnityEngine.Events.InvokableCallList.Invoke (System.Object[] parameters)
7 UnityEngine.EventSystems.ExecuteEvents.Execute [T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.EventFunction`1 functor)
8 MyTouchInputModule.ProcessTouchPress (UnityEngine.EventSystems.PointerEventData pointerEvent, Boolean pressed, Boolean released)
9 MyTouchInputModule.ProcessTouchEvents ()
10 MyTouchInputModule.Process ()

Code: Select all

ES2.Save<SystemData>(SettingData.Instance.SystemData,"systemData");
according to https://developer.android.com/guide/top ... ermissions
If the device is running Android 6.0 (API level 23) or higher, and the app's targetSdkVersion is 23 or higher, the app requests permissions from the user at run-time. The user can revoke the permissions at any time, so the app needs to check whether it has the permissions every time it accesses permission-protected APIs. For more information about requesting permissions in your app, see the Working with System Permissions training guide.
If the device is running Android 5.1.1 (API level 22) or lower, or the app's targetSdkVersion is 22 or lower, the system asks the user to grant the permissions when the user installs the app. If you add a new permission to an updated version of the app, the system asks the user to grant that permission when the user updates the app. Once the user installs the app, the only way they can revoke the permission is by uninstalling the app.
It seems player has denied the permission. How to check if we have the permisson in unity?
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: UnauthorizedAccessException

Post by Joel »

Hi there,

The only way we are aware of the check the permission in Unity is to attempt to access or create a file in the folder, and use a try/catch statement to check whether an UnauthorizedAccessException occurs.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
leo414
Posts: 5
Joined: Thu Dec 08, 2016 3:20 am

Re: UnauthorizedAccessException

Post by leo414 »

Hi!
It just thow the UnauthorizedAccessException without any other side effects if I don't use try/catch statement.?
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: UnauthorizedAccessException

Post by Joel »

Hi there,

You should catch it, otherwise it may stop execution of the application altogether.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Locked