Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

WebView: Path to Application Data

Hey guys - Im using a WebView to get access to pixel information via canvas.

I'd like to load a photo from the library and save a copy to the app data folder (this works fine), but I then need to load that photo to an image object, in a WebView. Is it possible to get the URL of this image; absolute or relative?

I've tried installing a copy of the HTML to the app data folder to use local paths. This actually works in the simulator, but does not work on the iPad. I don't mind digging some more, but I don't know if I'm wasting my time.

Cheers! :-)

More information and a solution:

This was an incredibly painful issue to figure out. Upon further inspection, everything was being installed on device except for the HTML document. This was not true for the Simulator, where both were installing just fine.

For background, I was installing an HTML and JPG document from Resources to the Documents folder (Application Data) - However, only the image document was installing correctly.

Solution? I changed the extension of the HTML document to TXT and it works just fine.

Something to do with the encoding? Maybe extension length? Possibly. For now, the solution works, but it's time to go cry in a pillow for taking so long to find an answer. :-)

As with my issues in the past, do note that if it works in the Simulator, it doesn't always work on device. Third issue where this has been the case.

Final testing. This did seem to be an issue with extension length. Went with .htm and everything is good. Silly inconsistency. ;-)

— asked July 16th 2010 by Fred Spencer
  • application
  • canvas
  • data
  • gallery
  • html5
  • images
  • photo
  • webview

3 Answers

  • If it works in simulator it must work on device too.

    Take care that the device is filename case sensitive while the simulator is not.

    — answered July 16th 2010 by Dan Tamas
  • Solution is above. :-)

    — answered July 17th 2010 by Fred Spencer
  • If a file is in the Application Data directory for an app (which is the only place files can be written) the reference (src for an img tag) needs to be prefixed with file:/// followed by the full system path to the resources directory.

    more information on our blog

    — answered April 6th 2011 by Mike Bopp
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.