Can WebView reference images in ResourceDirectory?

I’d like to take an HTML template, re-write it on the fly, then display it in a webview … with images that may be located in the system.ResourceDirectory.  

But I can’t create the temp file (the rewritten template) inside the ResourceDirectory since it is read-only.

If the images and temp file are all in DocumentsDirectory, then everything works.  But that means I’d have to copy any/all image files from ResourceDirectory to DocumentsDirectory before I display anything.  Not terribly hard, but it means 2x the memory usage on the device.

Is there a way to get a WebView to reference Res-Dir assets, even if the base-url is in Doc-Dir?  is there a prefix I can add to URLs to point at Res-Dir?  does it help if the temp file is in the Cache or Temp dirs?  is there a concept of a sym-link I could use?

 local path = system.pathForFile( "page1.html", system.DocumentsDirectory ) local file = io.open( path, "w" ) file:write( text ) -- text includes the re-written template code io.close( file ) file = nil -- create a webview local webview = native.newWebView( 0,0, display.contentWidth, display.contentHeight ) webview:request( "page1.html", system.DocumentsDirectory )

Yes you can! I’m currently doing that in an app that uses HTML. You just need to reference the full path, e.g

[lua]local imagePath = system.pathForFile( “images/imageTest.png”, system.ResourceDirectory )[/lua]

Ahh … thanks TandG … that works!

I’ll just have to pre-process the template file for references to images and re-write them (along with the other re-write rules that I’ll have).

Yes you can! I’m currently doing that in an app that uses HTML. You just need to reference the full path, e.g

[lua]local imagePath = system.pathForFile( “images/imageTest.png”, system.ResourceDirectory )[/lua]

Ahh … thanks TandG … that works!

I’ll just have to pre-process the template file for references to images and re-write them (along with the other re-write rules that I’ll have).