Storing remote images locally
I'm looking for a solution to store remote images (URLs retrieved from a RSS-feed) into the local file system so the images can be displayed in offline-mode too.
Is there any solution for that with Titanium?
2 Answers
-
Kitchen Sink has a couple of examples that show how to do this. In particular, you could look at xhr_binarydata.js.
Here's an example:
var xhr = Titanium.Network.createHTTPClient(); var dir = Ti.Filesystem.applicationDataDirectory; xhr.onload = function() { var f = Ti.Filesystem.getFile(dir,'ti.png'); f.write(this.responseData); imageView.url = f.nativePath; }; xhr.open('GET','http://yourpath'); xhr.send();
fetches a remote PNG file and stores into a file. then loads the image view from the files path.
-
regarding image storage, can we also store the rss feeds images and their pertaining texts locally in android?
so that if the mobile has no network connection, it shall take from cache or db ?