Search code examples
androidcordovaphonegap-desktop-app

Phonegap/Cordova: img tag not displaying images from SDcard


I'm new to Phonegap/Cordova and building an app using MaterializeCSS and JQuery on Android OS 5.1. I have a problem that no images in the IMG tag seem to be loading, but the file paths seem to be correct.

I have my app scripted so that images are downloaded from my server to

"file:///storage/emulated/0/Android/data//files/images/".

I have a static index page with a content DIV, modified using jquery:

$("#rBody").html('<div class="row"><div class="col s12">'+jxml+"</div></div>");

Therefore, content is dynamically loaded. the IMG tag src path property is modified as per platform:

jxml=jxml.replace("images", app.getStorageLocation()+"files/images");

However, the image placeholders just have a blank square instead as if image is not found.

Is there any reason for this to occur? Is there a permissions property somewhere I need to enable?

Thank you for any advice!


Solution

  • You will need both file permissions and the File API plugin for Cordova.

    With these you should be able to read the image in and add it to the tags.