Preferences storage location?
The Preferences API provides a transparent way to store preferences. But I can't find a method to retrieve the actual storage location on the system. I read in the forums that on Windows they are stored in the registry. On Unix in ~/.java/.userPrefs. But I would like to have a generic API to get the location.
The reason is simple and also quite important: if a user wants to uninstall my application, the preferences are left on the system. AT least I need to tell the user where they are stored so he can remove them too.
That's very kind of you, but also very non-standard. I very rarely encounter applications whose uninstallers clean up completely, or even provide an option to do that.
However you already have an API which, although it doesn't give you the "location" of the preferences, allows you to delete all the preferences. It's the java.util.prefs.Preferences class itself.
You wouldn't want to tell the user that the preferences are in the Windows registry anyway. Most users are unaware that it even exists, and deleting entries from the registry is a dangerous process that shouldn't be done by the uninitiated.
> ? That's all for a clean removal of all preferences
> of my application?
Like camickr says, give it a try. However, I think that different users who run your application get different preferences, so on the face of it I would say that it would be difficult to track down other users' preferences and delete them too. Perhaps that's another reason why uninstallers typically don't try that.
The best advantage of using Preferences is that it doesn't get deleted when you uninstall your application and delete the program folder.
This way you can keep user preferences if the user just uninstall the current version, and then installs a new version of the same application.
If you want the preferences to be deleted, you should use java.util.Properties and save the preferences in a file in the application folder that will be deleted with the applciation.