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:

   
 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  
  

that works fine on iPhone.
on Android I had to move all files to the root folder (before in a subfolder)
and still i get a
path: file:///android_asset/index.html
flags: “rb”

and a NIL as result for -> served = io.open(path,flags) – flags = “rb”

How to set the right path or base on Android?

thx
chris
[import]uid: 4795 topic_id: 18989 reply_id: 318989[/import]

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
[import]uid: 4795 topic_id: 18989 reply_id: 73127[/import]

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
[import]uid: 4795 topic_id: 18989 reply_id: 73211[/import]

any news… looks I have to fill a bug report :frowning: [import]uid: 4795 topic_id: 18989 reply_id: 73595[/import]

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. [import]uid: 52491 topic_id: 18989 reply_id: 73667[/import]

@peach.

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

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

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 =

  
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   

it just try to open each of that file. The Result till now: Only the .css file is found and opened!
all other are returned by pathforfile, but could not be opened.

Please, thats quiet urgent to have done and it really looks like a bug. Should u give that
Source to someone who can check it on an Android Device and do asap a fix for that.

1000 Thanks
Chris
[import]uid: 4795 topic_id: 18989 reply_id: 73773[/import]

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 :slight_smile: [import]uid: 52491 topic_id: 18989 reply_id: 73860[/import]

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
[import]uid: 4795 topic_id: 18989 reply_id: 73942[/import]