Image 钛合金-将图像从互联网保存到Android上的SD卡

Image 钛合金-将图像从互联网保存到Android上的SD卡,image,save,titanium,appcelerator,sd-card,Image,Save,Titanium,Appcelerator,Sd Card,我有一个钛Appcelerator和Android的问题。我想将一个图像从internet保存到我的SD卡。我该怎么做 var externalSrc = "http://example.com/image.jpg"; saveButton.addEventListener('click',function(e) { //?!? }); 非常感谢您的帮助。我还没有在Android上尝试过该代码,但在iOS上效果很好 var c = Titanium.Network.createHTTPCli

我有一个钛Appcelerator和Android的问题。我想将一个图像从internet保存到我的SD卡。我该怎么做

var externalSrc = "http://example.com/image.jpg";

saveButton.addEventListener('click',function(e) {
//?!?
});

非常感谢您的帮助。

我还没有在Android上尝试过该代码,但在iOS上效果很好

var c = Titanium.Network.createHTTPClient();
var f = Titanium.Filesystem.getFile(directory, filename); // Here is the path to save the file.
var url = '/url/to/image.jpeg';
c.onload = function() {
    // File saved
};

c.ondatastream = function(e) {
    // Progress value in e.progress;
};

c.onerror = function(e) {
    // error
};

c.open('GET', url);  // open the client
c.setFile(f);
c.send();    // send the data