I'm stuck on downloading a text

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.

It works fine in the emulator.

https://developer.anscamobile.com/content/network

What to do?

I'v solved it. But it has to be a easier way?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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"

Sorry for my uncleanliness.

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. :)

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.

views:1751 update:2011/10/9 9:57:41
corona forums © 2003-2011