2016-06-17 3 views
2

저는 CodenameOne을 (를) 처음 사용하게되었습니다..properties 속성 액세스

나는 "codenameone_settings.properties"나는 "http://localhost:3000는"

가 어떻게이 속성에 액세스 할 "myapi"라는 새로운 속성을 추가라는 파일을 참조하십시오?

System.out.println(Preferences.set("myapi", "nono")); 

나는 "아니요 아니요"얻을

답변

5

을 "codenameone_settings.properties는"응용 프로그램에 액세스 할 수없는 프로젝트 구성 파일입니다 : 내가 할 때 나는

Preferences.set("myapi", "nono") 

을 시도했다. 속성 파일을 앱에서 사용해야하거나 필요로하는 경우 프로젝트 src/폴더에 고유 한 속성 파일을 추가하고 코드에서로드하십시오. 예를 들어

:

//place the App_settings.properties under the src/ dir 
    Properties conf = new Properties(); 
    conf.load(Display.getInstance().getResourceAsStream(getClass(), "/App_settings.properties"));