get local file on android (iPhone works)

Hi,
I like to open a file that is in my root folder (where my main.lua is)

i use:

1
2
3
4
5
6
7
8
 
 file = 'index.html"
 local base = system.ResourceDirectory          
 path = system.pathForFile(file, base )
 if path then 
        print ("in path")
        served = io.open(path,flags)    -- flags = "rb"
  end

very strange

i have this files in my resource folder (where the main.lua is)

index.html
index.css
backup.png

when i request index.css it does find the file and give me:
path: /data/data/com.chris.mydayscorona/files/coronaResources/index.css

but index.html gives:
path: file:///android_asset/index.html

and backup.png
path: backup.png
also does not work

i also tried manually to set the path same as index.css so for example
/data/data/com.chris.mydayscorona/files/coronaResources/backup.png
/data/data/com.chris.mydayscorona/files/coronaResources/index.html

both not found on a real Android Device (nexus one) ... on iPhone works fine, all found.

i am really confused who... why only index.css is found, please help !!

thx
chris

any news here?
please, why can i find AND open any .css file in my resource folder,
but not any other file like .html , .png etc?

thats in my resource folder

aaa.css
bbb.css
aaa.html
bbb.html
aaa.png
bbb.png

system.pathForFile(file, base ) > does only create a proper path for the .css files ... all other do not come found while trying to open with > io.open(path,"r")

thx
chris

any news... looks I have to fill a bug report :(

Is that a typo in your original post? You seem to have messed up a string by using ' and ".

I don't work with Android so can't advise on the rest of it, however that code snippet is of some concern.

@peach.

its cool you keep up on that postings :) thanks.

yes its a typo.... but not in the original code (otherwise it would not work at all :)

anyhow.. the bug still resists on an Android Device.
I did a test app, you can download here and just install on a android device.

http://www.2t4u.com/!testapps/coronaandroidtestapp_openressources.zip
its source & compiled.

the app itself is just a folder with:

aaa.css
aaa.htm
aaa.html
aaa.jpg
aaa.png
main.lua

----main.lua =

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
mytext=native.newTextBox( 0, 0, 320, 480 )
mytext.size = 8
result = ""
 
function tryopen(whatfile)
         local base = system.ResourceDirectory          
         result = result .. "\n----\nsearch for path:"
         path = system.pathForFile(whatfile, base )
         if path then 
                result = result .. "\nin path: "..path
                served = io.open(path,"r") 
                        if served ~= nil then
                    result = result .. "\nYEAH! opened"
                else
                    result = result .. "\nARGG! -----> Path OK, but not opened !"
                end
          else
                        result = result .. "\nSNIEF! NO PATH!?"
          end
 
end  
 
  tryopen ("aaa.html")
  tryopen ("aaa.css")
  tryopen ("aaa.htm")
  tryopen ("aaa.html")
  tryopen ("aaa.png")
 
mytext.text = result      

I can pass this on to the team but it would be best if you had filed a bug report and I had a bug # to give them as well - have you filed one yet?

No worries on keeping up with the posts, I do my best - unfortunately Android just isn't my area and my testing options are somewhat limited at the present time.

Peach :)

I filled one already a bug report here

http://developer.anscamobile.com/forum/2011/12/13/cant-find-file-ressoure-directory-only-android

nobody answered till now... please keep on it as good as possible.

greets
chris

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