MATLAB: How to save changes to component properties in an AppDesigner app such that the changes are preserved when I close and re-open the app

componentloadMATLABpersistentsaveuiuifigure

I am creating an app in App Designer and I would like to allow users to change certain properties of components in the app such that the changes are preserved when they close and reopen the app.
For example, say I have a 'TextArea' in my app which has the value, 'hello'. I open the app, change the value to 'goodbye', and close the app. Next time I open the app, the 'TextArea' should still have the value, 'goodbye'.
How do I make this happen?

Best Answer

One way to accomplish this is to save the data to a MAT file using "save" in the app's "CloseRequestFcn" callback and then load the data into the app using "load" in the app's "StartupFcn" callback. Documentation for the "save" and "load" functions can be found at the links below:
An app demonstrating this method, 'appTest.mlapp', is attached for reference. Note that after you enter characters in the text area, you need to left-click the mouse outside the text area in order for the change to take effect.