2017년 3월 19일 일요일

Saving Images on your Device


Hello all, I am using App Inventor 2, which I like very much, and I am working on a picture game app.
I used the principles in the old WebPrefetch, with some slight variations for the output file names, to try an keep the app size minimal.
The app is working beautifully for my Android tablet, but I have run into a slight snag.
When I pull the images off of my webserver i save them to the store directory of:
STORE DIRECTORY = "/data/nisi/"
To recover the images to view the Load directory for my tablet is actually
LOAD DIRECTORY" = "/storage/sdcard0/data/nisi/"
I noticed that the Webprefetch example's load directory was different and upon trying this on my wife's Galaxy S4 found that the path is yet again different.
So in a word, I am assuming every android device has a different storage path unique to the model of the the device. This is not entirely unexpected, but I I am now at a stand still.
So a couple of questions here.
1. Is there a way to auto detect the full path name and update my Load Directory variable once an image is saved.
2. Is there a way to download images off the web and save the images within the app directory so you do not need any of the prefixes to access the images.
Any ideas or suggestions would be gratefully appreciated.

--
do you use Shival Wolf's web prefetch?
1. Is there a way to auto detect the full path name and update my Load Directory variable once an image is saved.
try file:///mnt/sdcard and check, if that path to the sd card works with all devices
2. Is there a way to download images off the web and save the images within the app directory so you do not need any of the prefixes to access the images.
no
well, probably possible with a rooted device?

--
Thanks for the quick response Taifun.

Yes I did use the basic Webprefetch from Shival Wolf.

I was trying to add a screen shot, but this seems to be turned off, or is not showing anyway of doing this on my screen.

I have the prefetch downloading 6 images at a time.  Each set copies over the previous set so you do not eat up the device memory. The /mnt/sdcard/is it... I couldn't remember what Shival Wolf's had, for some reason his site is not working ... looks like some kind of server error.

I tried this first, /mnt/sdcard/data/nisi/, and couldn't get it to work, however Shival's is not exactly how you have it listed.

Mine is currently set as "/storage/sdcard0/data/nisi/"

So you are suggesting I try  "file:///mnt/sdcard/data/nisi/" this of course followed by the file name itself?

I will play around with it.  I'm not really a programmer so I am assuming the number of /// is the difference here. 

--
Shival Wolf's tutorial is here http://ai.kittywolf.net/index.php/Webprefetch

try /data/nisi/ as storeddirectory 
and file:///mnt/sdcard/data/nisi/ as loaddirectory
Taifun

PS: another webprefetch version you can find here http://puravidaapps.com/filebyfile.php
That version avoids problems which can occur with larger files...

--
Thanks very much, I will try later this weekend and let you know.

--
Hello Taifun, thanks again.

That worked beautifully.  I have tried it on several devices and they all seem to work perfectly.

Also what I was saying about Shival's website. This is the message I am getting.

Error 418

I'm a Teapot
Kambrook/2.1.4 (Electric) Kettle Server at ai.kittywolf.net Port 80 


--
Sorry the "Thanks Agin" is not in the error page :)

--

댓글 없음:

댓글 쓰기