×
Namespaces

Variants
Actions

How to remove locally created files during uninstall

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Article
Created: aaumala (30 Oct 2007)
Last edited: hamishwillee (26 Jul 2012)

Problem
Uninstall does not remove all files that were created either during the installation of the application or during the execution of the application. (This problem can prevent an application passing Symbian Signed testing).

Solution

Ensure that all files created on the device during the installation or execution of the application are removed on uninstall. If the name and location of the files/directories are known beforehand, the FILENULL option in the package file can be used to remove them during uninstallation. Masks can be used with FILENULL to remove a group of files (in your .pkg file):

...
"" - "!:\system\apps\SomeApp\temp.dat", FN
"" - "!:\system\apps\SomeApp\*.log", FN
...

See the package file format description in the SDK Help for more information on using FILENULL.


S60 3rd Edition

Since Symbian OS v9.1, there is an easier way to ensure that application files are removed during uninstall. The private folder should be used to store application-created files; this folder will be removed automatically during application uninstall. The private folder usually has the form “\Private\<SID>\”. The private folder can be requested at run time with the RFs::PrivatePath(…) method. The following example demonstrates how a file can be created in the private folder:


_LIT( KTempFilename, “temp.dat);
 
TFileName tempFilePath;
RFile tempFile;
 
RFs fs;
User::LeaveIfError( fs.Connect() );
CleanupClosePushL( fs );
 
fs.PrivatePath( tempFilePath );
tempFilePath.Append( KTempFilename );
 
User::LeaveIfError( tempFile.Create( fs, tempFilePath, EFileShareExclusive | EFileWrite));
CleanupClosePushL(tempFile);
 
// write something to tempFile
 
CleanupStack::PopAndDestroy(); // tempFile
CleanupStack::PopAndDestroy(); // fs


Usually the private folder will be created during installation if an application installs, for example, a backup registration file “backup_registration.xml”. Otherwise, RFs::CreatePrivatePath(…) can be used to explicitly create the private folder at run time.

Any files created outside the private folder have to be removed as well, provided that the name and location of the files can be determined. An application can leave user-created content on a device if the user selects to keep the files. To implement such behavior, an application with a confirmation dialog could be launched on uninstall using the FILERUN option in the package file. The confirmation application would ask the user whether to remove user-created files and then remove them afterward. See the SDK Help for more information about FILERUN in the package file format description.

Note that if the application creates a folder to the Application menu in which the application is installed, the folder is not removed. This is an S60 platform feature and therefore accepted. However, it is recommended to install applications to the default folder.

This page was last modified on 26 July 2012, at 03:12.
32 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×