Delete file from Resources directory
How can I delete file that is somewhere in resources directory?
Below you can see my folder structure:
var filePath = Ti.Filesystem.resourcesDirectory +
 Ti.Filesystem.separator + 'app' +
 Ti.Filesystem.separator + 'views' +
 Ti.Filesystem.separator + 'WebViewFolder' +
 Ti.Filesystem.separator + 'images' +
 Ti.Filesystem.separator + 'image.png'
var file = Ti.Filesystem.getFile(filePath);
Ti.API.info(file.exists());
file.deleteFile();
Ti.API.info(file.exists());
And this is the output:
[INFO] 1
[INFO] 0
But even if it says 0 which means that the file is deleted, I see the file in folder structure and on application restart I get the same output:
[INFO] 1
[INFO] 0
Files that I am creating and deleting has to be on that location because I am referencing them from inside WebView's javascript code.
This is the full folder structure:
Resources
    - app
        - views
            - WebViewFolder
                - html
                    - index.html
                - js
                    - file.js 
                        - here I can reference image like:
                        var image = new Image();
                        image.src = "../images/image.png"
                - images
                    - image.png
file.js sees only the WebViewFolder and can't see file that are somewhere else (Titanium.Filesystem.applicationDataDirectory)
Why can't I just simply create/delete files in that images folder?
iPhone, Titanium SDK 1.8.1
1 Answer
- 
				
					
Accepted Answer
The whole Resources folder is readonly.. it may work on the simulator, but on the device it will cause a permission error