This is my first post,Thank you for your help. When the app is about to run,
it will crash because there is no storage permission
in the main
B4X:
Sub Activity_Create(FirstTime As Boolean)
rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
If Result = False Then
ToastMessageShow("..........", True )
Sleep(1000)
ExitApplication
End If
...........
End Sub
in the starter.bas
B4X:
Sub Service_Create
Dim dir As String
dir = File.DirDefaultExternal
If Not (File.Exists( dir, "sd.db") ) Then
File.Copy(File.DirAssets, "sd.jpg", dir, "sd.db" )
End If
SQL1.Initialize( dir, "sd.db", True)
End sub
1. Service_Create of the starter service is run before the permission is requested.
2. You don't need a permission at all. Watch the runtime permissions video tutorial and it will be clear.
You need to use RuntimePermissions.GetSafeDirDefaultExternal.
3. I would have used File.DirInternal instead. Save yourself crashes that will happen when the secondary storage is not available.