I’m trying to download the text from a file on the Internet and it works fine if i wont to save it to the DocumentsDirectory, a file is created but i can’t get the text to end up on my Android screen.
function hamtaData3()
local path = system.pathForFile( "something.shtml", system.DocumentsDirectory )
local htmlFile = io.open( path, "w+b" )
-- Request remote file and save data to local file
http.request{
url = "http://wdo.se/Corona",
sink = ltn12.sink.file(htmlFile),
}
local fh, reason = io.open( path, "r" )
if fh then
local contents = fh:read( "\*a" )
htmlHamta.text = contents
end
io.close( fh )
end
I don’t really understand your question? What exactly did you solve? The above code downloads a file to the documents directory then copies the contents to a ‘global’ variable htmlHamta. There is nothing to do with displaying here… “i can’t get the text to end up on my Android screen” [import]uid: 23949 topic_id: 6355 reply_id: 22075[/import]
The htmlHamta.text is a display object showing the received data.
The problem i had was that after the phone had download the text from Internet the response would not show up on the screen. Now when i read the response from a file it works!
I’m new at Corona an LUA so cut me some slack. [import]uid: 28895 topic_id: 6355 reply_id: 22128[/import]
No problem I was at work when I wrote that, and I just couldn’t work out what you were asking. I’m new at Corona as well. [import]uid: 23949 topic_id: 6355 reply_id: 22138[/import]