Open the following files and explore the different persistence services:
www/js/services/memory/ConferenceService.js
www/js/services/json/ConferenceService.js
www/js/services/localstorage/ConferenceService.js
www/js/services/websql/ConferenceService.js
The application is initially configured to work with the in-memory datastore. To change the local persistence mechanism for the application:
In index.html: instead of js/services/memory/ConferenceService.js, import the .js file for the service of your choice, for example: js/services/websql/ConferenceService.js.
Test the application.
To test the JSON service, make sure the Node.js server provided as part of the materials is running:
Open a terminal or command window, and navigate to the server directory under the phonegap-workshop project you downloaded.
Install the server dependencies:
npm install
node server
The server implements CORS (Cross-Origin Resource Sharing) to support cross-site HTTP requests. You can therefore invoke the services from a file loaded from another domain or from the file system.
Since services/json/ConferenceService.js points to localhost, this will only work when running the application in the browser on your computer, and not on your device because it doesn't know your computer as "localhost". To make the JSON service work when running the application on your device, make sure your computer and device are on the same subnet, identify the ip address of your computer, and replace localhost with that ip address in services/json/ConferenceService.js. As an alternative, you could also deploy the service on a publicly available server. In a real-life application, you would typically externalize the host name in some sort of configuration file.
All other data storage services provided in www/js/services work out-of-the-box when running the application in the browser and on device.