it’s really a simple task that won’t work and I don’t get it why since three days. Oh please, help someone! My brain gets hurt.
So I’ve an Android device with Android 4.4.2 (not rooted or anything). In my download folder at “/storage/emulated/0/Download” is a jpeg, lets call it “success_016.jpg”.
I can look at that pic with chrome (device browser) by requesting: “file:///storage/emulated/0/Download/success_016.jpg”, allright, file is accessible and not broken.
So, I create a new blank ionic project with: “ionic start whatever blank”. The new project gets the Android platform with the cli call: “ionic platform android”.
I keep everything unchanged, but insert in the index.html:
<img src=“file:///storage/emulated/0/Download/success_016.jpg” />
between the ion-content tags.
I start the app with: “ionic run --livereload --consolelogs --serverlogs android”, and the app starts on the device successfully, but the app doesn’t show the local image on the device (and it is there, explicitly).
Changing the attribute of the image-tag to “ng-src”? Nope, no differences. Changing to an remote file (via http://…)? Yep, it shows the remote file. Changing back to the local file (via file://… see above). Nope, it won’t show the local file from device.
I know, there are app folders and i should use the one of the app. No luck anyway. The local picture on device don’t got be shown in any view or img-tag with no src-attribute or ng-src-attribute. It’s a simple local html file request and it does not work!
Oh please HELP! I do not get it why the view won’t show the local html requested jpg file. Can anybody make my day?
PS: I wrote an(other) app that downloads pictures (sync-process) to something like: “/storage/emulated/0/Android/data/com.ionicframework.work1234/files/”. But if I try to show a picture in that path <img src=“file:///storage/emulated/0/Android/data/com.ionicframework.work1234/files/mypic.png” IT WONT GOT SHOWN
There is the img-folder in my project-folder, path: www/img on my Windows development work station. If I place the mypic.png to that folder, I can SHOW it with <img src=“img/mypic.png”>. No problem. The problem is only … I don’t know, how to place it on download (with cordova-filetransfer) to that project-img-folder (at www/img).
Why? Look …
I have TotalCommander (file explorer) on my Android. I search for that folder or picture but it’s not there. If I could find and access (even with cordova-file) the path of www/img, I would download and place the pictures to that folder and show them in a view with the img-tag and the relative path src=“img/mypic.png”. But even mypic.png cannot be found on the hole device file system nor the path to www/img.
I request the download target path in that other project with cordova.file.externalDataDirectory …
Another test …
I create a local html file:
The first image tag loads a local image. The second loads a remote one. I start that local HTML-file in the Chrome browser on the Android device. It shows me the local and remote file. So … local file access with absolute paths are no problem for the device.
The view in the app is (I think so) a html-page. It has absolute paths to local image files. But it WONT show that images. If I replace those absolute local image paths to remote local image path, the pictures in the app on that html page / ionic-view gets shown. Why not for local files??? What am I missing?