2017-02-19 22 views
1

Я сохранил изображение в Ti.FileSystem (appcelerator) и успешно сохранено. Но я не могу взять его обратно и отображение в ImageViewИзвлечь изображение, сохраненное в прикладной программе Ti.Filesystem

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'); 
} 

ответ

2

Вы можете просто использовать $.id_buttonImage.backgroundImage=fileForm.nativePath; после проверки, если она существует. Поскольку это уже ссылка на файл, вам не нужно снова создавать путь.