本文共 2277 字,大约阅读时间需要 7 分钟。
Eclipse Preference Scope
INSTANCE - The instance scope can also be thought of as "workspace". That is, the preferences which are stored in this scope are stored per workspace, or per running instance of Eclipse. This scope corresponds to the default location of preferences in Eclipse 2.1. The instance area is derived from the location returned by org.eclipse.core.runtime.Platform#getInstanceLocation(). Preferences stored in this scope will not be available to other running instances of Eclipse.
CONFIGURATION - The configuration scope is used to store preferences on a per configuration level. Being able store preferences per configuration means that all workspaces share the same preferences. For instance, if you are an Eclipse developer and you have a single Eclipse install but you have multiple workspaces for different projects/branches that you are working on, the preferences stored in the configuration scope will be shared between these workspaces. The configuration area is derived from the location returned by org.eclipse.core.runtime.Platform#getConfigurationLocation().DEFAULT - The default preference scope was initially created to provide a backwards compatibility story for the plug-in customization code in Eclipse 2.1. Preferences stored in the default scope are not persisted to disk and are a part of the plug-in customization story.PROJECT - There was a request for per project preferences so the project scope handles this. Preferences which are stored in this scope are shared stored in the project content area and are therefore automatically shared with the repository. This enables items like java compiler settings to be shared between team members working on the same project.INSTANCE and CONFIGURATION are used in most situations.Store data in Preference:INSTANCE...Preferences preferences = new InstanceScope().getNode("foo.bar.MyPlugin");preferences.put("key", "value");try { preferences.flush(); } catch (BackingStoreException e) { e.printStackTrace(); }...CONFIGURATIONPreferences preferences = new ConfigurationScope().getNode("foo.bar.MyPlugin");preferences.put("key", "value");try { preferences.flush(); } catch (BackingStoreException e) { e.printStackTrace(); }...Load data in Preference:preferences.get("key", "");转载地址:http://rnmhj.baihongyu.com/