Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
Posts: 48
Registered: ‎10-11-2012
My Device: Z10
My Carrier: none

How to load image from "data" folder into WebView ?

Hello !

I am trying to load local html page that contains img loaded by the app in "data" folder, so in the html doc image must be inserted like as

<img src="local:///data/this_is_img.png" alt="My Image" />

 and this is not working, also if img has full path starting from "file://"

 

But if image is located in assets this is working :

<img src="local:///assets/this_is_img.png" alt="My Image" />

 So, question is how to insert image from data folder ?

 

 

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: How to load image from "data" folder into WebView ?

[ Edited ]

Because it's not local, it can be accessed using QDir::homePath()...

 

http://developer.blackberry.com/native/documentation/cascades/device_platform/data_access/file_syste...


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 48
Registered: ‎10-11-2012
My Device: Z10
My Carrier: none

Re: How to load image from "data" folder into WebView ?

I found that this is maybe a problem because similar question was not solved

http://supportforums.blackberry.com/t5/Native-Development/Access-to-app-s-working-directory/td-p/262...

 

I tried this but only the first image is displayed, so how to open image from data folder ?

<img src="local:///assets/main_menu_menu_btn_selected.png" alt="My Image" />
<img src="file:///main_menu_menu_btn_selected.png" alt="My Image" />
<img src="file:///../../../../../../data/icons/resize/72x72/182.png" alt="My Image" />
<img src="file:///../../../../../data/icons/resize/72x72/182.png" alt="My Image" />
<img src="file:///../../../../data/icons/resize/72x72/182.png" alt="My Image" />
<img src="file:///../../../data/icons/resize/72x72/182.png" alt="My Image" />
<img src="file:///../../data/icons/resize/72x72/182.png" alt="My Image" />
<img src="file:///accounts/1000/appdata/com.example.testapp.testDev_mple_testapp5dbaf0_/data/icons/resize/72x72/184.png" alt="My Image" />
<img src="file://accounts/1000/appdata/com.example.testapp.testDev_mple_testapp5dbaf0_/data/icons/resize/72x72/184.png" alt="My Image" />
<img src="file:///accounts/1000/appdata/com.example.testapp/data/icons/resize/72x72/184.png" alt="My Image" />

 

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: How to load image from "data" folder into WebView ?

You'll see from that post that I indictated a difference between how file: and local: are handled within WebView.

 

Your only option currently is to place you files in a shared directory and access from there.

Remembering to remove the files after use so not to fill the users folders, I would recommend a tmp folder.

 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: How to load image from "data" folder into WebView ?

To allow access via the file mechanism for the browser or webview would violate security of an apps directory.


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 48
Registered: ‎10-11-2012
My Device: Z10
My Carrier: none

Re: How to load image from "data" folder into WebView ?

So WebView have not the same right as app ? And I have to interact with WebView as with third party application using shared folder  ?

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: How to load image from "data" folder into WebView ?

Effectively yes.


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 48
Registered: ‎10-11-2012
My Device: Z10
My Carrier: none

Re: How to load image from "data" folder into WebView ?

Thank you I'll try, but this behavior is very strange and not clear.

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: How to load image from "data" folder into WebView ?

If you think of it from a security point of view it makes perfect sense for file and local to be handled differently, what's not clear however is why local is not able to access the data directory I see no reason why a relative path should not work.  However I have tried many variations and cannot get it to work so there is some underlying mechanism there for some reason currently only clear to the OS designers. 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Highlighted
Developer
Posts: 48
Registered: ‎10-11-2012
My Device: Z10
My Carrier: none

Re: How to load image from "data" folder into WebView ?

tried with no luck, no images are displayed

(permissions added, image is copied to shared folder)

<img src="file:///shared/misc/testapp/icons/resize/72x72/182.png" alt="My Image" />
<img src="file:///accounts/1000/appdata/com.example.testapp.testDev_mple_testapp5dbaf0_/shared/misc/testapp/icons/resize/72x72/182.png" alt="My Image" />