Time for action – reading and writing data on the LocalStorage
Open the command-line tool and create a new PhoneGap project using the PhoneGap CLI you installed before. This will create a new directory called
DeviceApi
in your current working directory; this can be done using the following command:$ phonegap create DeviceApi
Move to the directory you just created:
$ cd DeviceApi
Add the platforms you want to test on the device API. For this example, we add the Android platform:
$ cordova platform add android
Delete all the files and subdirectories except
index.html
inside thewww
directory. Open theindex.html
file you will find in thewww
root folder and add the following HTML code snippet:<button type="button" onclick="addCountry()">Add Canada</button> <br/><br/> <button type="button" onclick="get1Data()">Get USA Data</button> <br/><br/> <button type="button" onclick="getAllData()">Get All Data</button> <br/><br/>...