访问 .properties 属性
Accessing .properties property
我是 CodenameOne 的新手,这个平台很棒。
我看到一个名为 "codenameone_settings.properties" 的文件 我添加了一个名为 "myapi" 的新 属性,“http://localhost:3000”
我如何访问此 属性?我试过了
Preferences.set("myapi", "nono")
当我这样做时:
System.out.println(Preferences.set("myapi", "nono"));
我得到"nono"
"codenameone_settings.properties" 是应用程序无法访问的项目配置文件。
如果您 need/want 要在您的应用程序中使用的属性文件,请将您自己的属性文件添加到项目 src/ 文件夹并从代码加载它。
例如:
//place the App_settings.properties under the src/ dir
Properties conf = new Properties();
conf.load(Display.getInstance().getResourceAsStream(getClass(), "/App_settings.properties"));
我是 CodenameOne 的新手,这个平台很棒。
我看到一个名为 "codenameone_settings.properties" 的文件 我添加了一个名为 "myapi" 的新 属性,“http://localhost:3000”
我如何访问此 属性?我试过了
Preferences.set("myapi", "nono")
当我这样做时:
System.out.println(Preferences.set("myapi", "nono"));
我得到"nono"
"codenameone_settings.properties" 是应用程序无法访问的项目配置文件。 如果您 need/want 要在您的应用程序中使用的属性文件,请将您自己的属性文件添加到项目 src/ 文件夹并从代码加载它。
例如:
//place the App_settings.properties under the src/ dir
Properties conf = new Properties();
conf.load(Display.getInstance().getResourceAsStream(getClass(), "/App_settings.properties"));