Methodology for saving field data between application sessions

时间:2015-07-08 15:58:12

标签: java windows encryption save registry

I'm working on an application that requires I save a field between application uses, so that I can retrieve the data during the next use (ex. save username when logged in, retrieve it and pre-populate username field when application is next launched). I've looked around and found a couple ways to accomplish this goal, such as encryption & saving in a file on the local machine, and saving the value in the Windows registry. Are any of these methods better than others for accomplishing this goal? Any other suggestions?

1 个答案:

答案 0 :(得分:1)

您可以使用Java Preferences API存储它,它将以系统特定的方式存储少量数据。在Windows上,我相信它会将其存储在注册表中,但在Mac或Linux上,它将以适合这些系统的方式存储。

对于当前用户,数据存储在特定于您的类包的键和您选择的字符串下。有关详细信息,请参阅Preferences API Overview