Hi everybody, I’m trying to download one configuration file that’s hosted on URL(it can’t be added directly to app because it changes every month). But since I need it to load other images and stuffs on my app, my code should stop until I had this downloaded complete.
I tried different ways and all of then just failed. Here’s the last try:
function downloadWait(link,filename) local function networkListener(event) isDownloading = true if ( event.isError ) then print("Network error - download failed") isDownloading = false elseif (event.phase == "began") then print("Progress Phase: began") isDownloading = true elseif ( event.phase == "ended" ) then print( "file downloaded" ) isDownloading = false end end function file\_exists(name) path = system.pathForFile(name, system.DocumentsDirectory) local f=io.open(path,"r") if f~=nil then io.close(f) return true else return false end end if not file\_exists(filename) then network.download(link,"GET",networkListener,filename) print("1") while isDownloading do print(isDownloading) end end end
But it never enter on the while loop.
Can someone help me ?
PS: Also another problem was that I can’t rewrite a file, maybe it has something on permissions that I forget?
Thanks, Pedro.