obaid
obaid

Reputation: 902

Fetch Image stored in Ti.Filesystem appcelerator

I have stored the image in Ti.FileSystem (appcelerator) and it is successfully stored. But I'm not able to fetch it back and display in ImageView

FullFileName="HA_2312751361_0566296329";
var fullFileNameForForm=FullFileName+"_form.png";
var fileForm = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,fullFileNameForForm);
console.log("contents="+fileForm); // It gets the contents of the file

if(fileForm.exists()){
    var contents=fileForm.read();
    var image=Titanium.Filesystem.applicationDataDirectory + Ti.Filesystem.separator + contents.image; 
    //it crashes in above line for contents.image
     $.id_buttonImage.backgroundImage=image; 

}
else{
    console.log('fileNotExists');
}

Upvotes: 1

Views: 89

Answers (1)

miga
miga

Reputation: 4055

You can just use $.id_buttonImage.backgroundImage=fileForm.nativePath; after you check if it exists. Since it already is a link to file you don't need to create the path again.

Upvotes: 2

Related Questions