Storing and Loading Data

We cover the storage and loading of images in Keyboard Input and Loading Resources. These images are added to Resources and are stored with the application on the website.

The equivalent of local files in Smart Mobile Studio is local storage, where single strings may be saved to a reserved block of memory in the browser. (As a security measure, JavaScript has no permission to save local files). The demonstrations start with the simplest, which saves then loads a single string. The second program saves the string only when run for the first time. The third demonstration shows you how to save a complete array as a single string then load the string and reconstruct the array.

These three demonstrations are based on program LocalStorage in the A Smart Book Demos folder. This program also covers the saving of data in cookies, the subject of our fourth demonstration. Another supplied demo in the same folder, HttpAndJsonp, shows ways of handling data stored on websites. When adapting it, you need to be aware that it will not work for local HTML files. We found that the outcome was very dependent on the browser. For our fifth demo, we have adapted the easiest HTTP part of the code that shows how to load a text file from the website that stores the application. This works in Chrome, Internet Explorer, Firefox and Opera. Our final example shows you how to use an application to run php scripts on the server to retrieve data stored in a MySQL database.

See also Datasets and Databases for storage of data in MySQL and Firebird databases and access via Node.js.


Follow the links below to sections of the storage tutorial.

Programming - a skill for life!

Developing graphical web pages including 3D, input from keyboard and mouse and storing and loading data