Data persistence refers to the existence of data in the program. In other words, it means the life of data.
Data is the most significant part of a program and it must be stored properly and easily retrieved when required. Before files came into existence, data was being stored in data variables of a program. The life of the data is till the program is executing.As soon as the program terminates, the memory alloted to the data variables is released and data is lost.
To run a program, it is first loaded in RAM (Random Access Memory) i.e memory is allocated to the program. Memory is allocated to the data variables. As soon as the program execution is finished, memory alloted to the variable is released. This is because the life of the data is till the program is executing. As a result, data gets lost.
In critical scenarios like Online Bank Transcation, where data is the integral part, data variables are not sufficient for storage. Therefore, a permanent data storage solution is required for easy access and reliable storage.
Solution to the above mentioned problem is : Before the destruction of the data variable, the data should be stored in some permanent storage (Secondary memory) i.e., Hard Disk.
Data is stored in the form of files in Hard Disk.