Has Permission > error:
Public Sub HasPermission As Boolean
Dim PreviousUriFileName As String
Dim List As List
If File.Exists(File.DirInternal, PreviousUriFileName) Then
PersistantURI = File.ReadString(File.DirInternal, PreviousUriFileName)
List = ctxt.RunMethodJO("getContentResolver", Null).RunMethod("getPersistedUriPermissions", Null)
If List.IsInitialized Then
For Each uripermission As JavaObject In List
Dim u As Uri = uripermission.RunMethod("getUri", Null)
Dim temp As Object = u
Dim s As String = temp
If s = PersistantURI And uripermission.RunMethod("isWritePermission", Null) = True Then
Return True
End If
Next
End If
End If
Return False
End Sub
Private Sub Depart
If HasPermission Then
FirstTime = False
FileList_Click
Else
Msgbox2Async("You need to create a folder for sound recordings.", "Create new folder ?", "Yes", "", "No", Null, True)
Wait For Msgbox_Result (Result As Int)
If Result=DialogResponse.POSITIVE Then
CreateNewDir
End If
End If
End Sub
Sub CreateNewDir
MusicTitle.Text="Please wait while the music files are copied and downloaded"
Storage.SelectDir(CF.Checked)
Wait For Storage_ExternalFolderAvailable
' Find a file on external storage or create it
cStoragePath = Storage.Root
'Installing a cookie File IN external Storage
FileName = "CookieFile.txt"
CopyFileToExternalStorage(File.DirAssets, FileName, Storage.root, "")
Log (FileName & " a été créé")
' Copying about ten downloaded music files to the directory chosen by the user
Log("Download files and copy to external storage")
ListSongName.Initialize
ListSongName = File.ReadList(File.DirAssets, "FilesList.txt")
For i= 0 To ListSongName.Size -1
Log (i)
Log(ListSongName.Size)
NewFileName(i)=ListSongName.Get(i)
Log(NewFileName(i))
FileName= NewFileName (i)
Jb.Download("https://www.marcalaindaniel.fr/MusicBoxPlayer/"& FileName)
Jb.GetRequest.Timeout = 100000
wait for (Jb)Jobdone
If Jb.Success Then
Log("Good News ! Download was successful : " & FileName)
IN = Jb.GetInputStream
DestinationFile = Storage.CreateNewFile(cStoragePath, FileName)
OUT = Storage.OpenOutputStream(DestinationFile)
File.Copy2(IN, OUT)
OUT.Close
IN.Close
Jb.release
nf = i + 1
MusicTitle.Text="Please wait while music file " & nf & " of 14 is downloaded"
MusicTitle.Text = MusicTitle.Text & CRLF & FileName & " has been successfully downloaded"
Else
Log("Bad News ! Download was not successful : " & FileName)
End If
Next
Sleep(5000)
MusicTitle.Text = ""
MsgboxAsync("Congratulations, you have successfully created your directory for recordings, 14 music files have been downloaded from the web.","User Directory Selection")
FirstTime = True
FileList_Click
End Sub