My-TO-DO-List App: Stored Information
The My-TO-DO-List app you have previously created has a great setback: each time we open the app, the tasks which we have added the last time we opened the app have disappeared. So you had to add them again. Find out how to update the app so that it remembers the previously added tasks.
Introduction
As you have seen in the previous lesson we can use a variable which will remain stored on the user's device. For this, we use a command like this: initialize (stored) variable (variableName). As a result, the information (in our case the list) will be persistent.
Programming the application
When we change the type of the varible from app in stored, we will notice that the last part of the command will disappear, the part in which we give a value to that variable. initialize (app) variable (myList) to empty list becomes initialize (stored) variable (myList). This is because the old command tells our program to create a new variable, which will conatain an empty llist. The new command, on the other hand, will tell our app to check if the myList variable is locally stored and, if yes, bring the information from the memory.
So, we will have to add new lines of code in order to initialize the myList variable. This will happen only one time, when the application is opened for the first time on that device. When Screen1 is opened, we add the following commands:
Initial version of the code
Updated version of the code