I'm developing a plugin for an Eclipse-RCP-Application. Now I would like to cache a file (as I don't wan't to access the internet, whenever it's needed). This file should be accessible even after relaunching the application. Where would be the best place for it?
I thought about the workspace/.metadata folder. But I'm not sure if that is the right place and how to retrieve the location information. This should work, but I did not yet manage to find ResourcesPlugin
ResourcesPlugin.getWorkspace().getRoot().getLocation().toString();
Can anybody give me a hint for the best place to store such a file?
If you don't want users to see the file use the plug-in 'state location'. You get this using:
The plugin's state location is a folder which is part of the workspace meta data (
.metadata/.plugins/plugin id
to be exact).You can put whatever you like in this folder. It is up to your plugin to manage this data.
You can get the
Bundle
in various ways, such as:or
Note: The code you mention in your question would put the file in the workspace and it would be visible to the user.
ResourcesPlugin
is in theorg.eclipse.core.resources
plugin.