Where should I save my own app prefereces?
10 views (last 30 days)
Show older comments
I have my AppDesigner-app and I want it to remember the settings from last session. How and where should i prefereably save the state of the program?
Accepted Answer
Guillaume
on 6 Feb 2017
If you want to do that properly, the directory (on Windows post XP) where to save the preferences would be:
fullfile(getenv('APPDATA'), yourprogramname) %and NOT matlab!
if you want the settings to get propagated to other domain computers the user log onto, or
fullfile(getenv('LOCALAPPDATA'), yourprogramname)
if the settings are local to the user and machine. IF the settings are the same to all users, then:
fullfile(getenv('PROGRAMDATA'), yourprogramname)
More Answers (1)
Walter Roberson
on 6 Feb 2017
Edited: Walter Roberson
on 6 Feb 2017
As a complete alternative to Guillaume's correct answer:
"Note: Preference values are persistent and maintain their values between MATLAB sessions. Where they are stored is system dependent."
These would be per-user.
By the way: I have found in practice that one of the real challenges of preference files is backwards compatibility. "Oh, gosh, a phi of 1.69 isn't even possible now! But if they had that in their preferences file 4 years ago then they must have been doing this kind of analysis and that requires interpreting the other preferences a completely different way...."
0 Comments
See Also
Categories
Find more on Downloads in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!