Mark Glowienko
Member
I am now trying to use the <bold>RuntimePermissions.GetSafeDirDefaultExternal</bold> function instead of <bold>File.DirDefaultExternal</bold> to read and write files to a safe external directory. Unfortunately this function is causing a fatal error when used in apps on my phone (running Android 10). The following tiny sample app crashes on my phone when the GetSafeDirDefaultExternal function is encountered . I see that there are some related posts on the forum but they don't show solutions that solve this problem. I've updated the <bold>tools</bold> directory and the other resources in the /Android folder as one post recommends but this function is still causing a fatal error. There must be a simple explanation for this problem because users are obviously using this function successfully.
<code>
Sub Process_Globals
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
Public xui As XUI
Dim rp As RuntimePermissions
xui.MsgboxAsync("test 1", "debug")
Wait for Msgbox_Result(Result As Int)
'This statement executes properly
xui.MsgboxAsync("File.DirDefaultExternal: " & File.DirDefaultExternal, "debug")
Wait for Msgbox_Result(Result As Int)
'This statement causes the app to crash!
xui.MsgboxAsync("rp.GetSafeDirDefaultExternal(): " & rp.GetSafeDirDefaultExternal(""), "debug")
Wait for Msgbox_Result(Result As Int)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
</code>
<code>
Sub Process_Globals
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
Public xui As XUI
Dim rp As RuntimePermissions
xui.MsgboxAsync("test 1", "debug")
Wait for Msgbox_Result(Result As Int)
'This statement executes properly
xui.MsgboxAsync("File.DirDefaultExternal: " & File.DirDefaultExternal, "debug")
Wait for Msgbox_Result(Result As Int)
'This statement causes the app to crash!
xui.MsgboxAsync("rp.GetSafeDirDefaultExternal(): " & rp.GetSafeDirDefaultExternal(""), "debug")
Wait for Msgbox_Result(Result As Int)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
</code>