Reputation: 51
I am developing a hybrid mobile application in which , i have to create a folder inside which i am storing the images using phone gap. I have a new issue .I want to remove that folder when uninstalling that app in ios and android using phone app.
Upvotes: 0
Views: 908
Reputation: 529
As Idan Adar told ,cannot delete the files at time of uninstalling programmatically. Instead if you can create folder and store the file in the app internal storage. It will automatically gets deleted. So for doing this we have the following steps. This steps were taken from the stack overflow link.
Creation of folder inside the internal storage
On Android: as per official API docs
add one of these two lines to config.xml:
<preference name="AndroidPersistentFileLocation" value="Internal" />
<preference name="AndroidPersistentFileLocation" value="Compatibility" />
Without this line, the File plugin will use Compatibility as the default. If a preference tag is present, and is not one of these values, the application will not start.
On iOS
add one of these two lines to config.xml:
<preference name="iosPersistentFileLocation" value="Library" />
<preference name="iosPersistentFileLocation" value="Compatibility" />
Without this line, the File plugin will use Compatibility as the default. If a preference tag is present, and is not one of these values, the application will not start.
Upvotes: 3
Reputation: 44516
I believe that if you create the file or folder within the application's sandbox and you then uninstall the application, the sandbox is removed as well, so this is handled by the OS for you.
You can review the Cordova File API documentation (the sections about filesystem layouts).
That said, you cannot "catch" the uninstall event of an application and perform some action at that time (which then makes even more sense for the OS to handle this for you). Worklight cannot help you with this either (or any other framework for that matter, native or web).
If you want stronger "control" of your files, you may want to manage them during the application's runtime, like check whether a file or folder is required to be stored or not.
If you create your file or folder outside of the sandbox, you may want to not-do that practice.
Upvotes: 1