简体   繁体   中英

How can I get the absolute path of the preference file for a particular plugin in eclipse plugin development?

I want to read the absolute path of the preference file for a particular plugin which is generally stored at:

Platform.getLocation() + "\.metadata\.plugins\org.eclipse.core.runtime\.settings\myPlugin.prefs"

Is there any way to get it directly somehow using eclipse provided Apis instead of hard-coding the 2nd part of the path?

This should give the correct location:

Bundle rt = Platform.getBundle(IPreferencesConstants.RUNTIME_NAME);

IPath path = Platform.getStateLocation(rt).append(".settings").append("myPlugin").addFileExtension("prefs");

The actual location calculation is in org.eclipse.core.internal.preferences.EclipsePreferences

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM