save application setting in java & javafx

杀马特。学长 韩版系。学妹 提交于 2019-12-01 12:20:25

If you need to save more user informations, you can use a database.
But if you need to save one user information, you can use Preferences :

Preferences pref;
pref = Preferences.userNodeForPackage(yourClass.class);
pref.put("yourPreferenceName","yourPreferenceValue");
//This create a String preference if it not exists or modify the value if 
//exists

Preferences pref;
pref = Preferences.userNodeForPackage(yourClass.class); 
String preference = pref.get("yourPreferenceName","yourPreferenceValue");
//This give you the value of the preference

If you want to know more about the preferences go here.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!