I am building my first iPhone app with CSS, HTML, Javascript and PhoneGap. I want to use SQLite as the database, so i am using the following tutorial as inspiration:
http://coenraets.org/blog/2011/10/sample-app-using-the-phonegap-database-api/
The following code determines weather to use data from the database, or to populate the database with data first:
function onDeviceReady() {
db = window.openDatabase("EmployeeDirectoryDB", "1.0", "PhoneGap Demo", 200000);
if (dbCreated)
db.transaction(getEmployees, transaction_error);
else
db.transaction(populateDB, transaction_error, populateDB_success);
}
After debugging, i found out that every time i run the app, it populates the database, so
if (dbCreated)
never executes.
I want to have a look at the SQLlite file, so i am using SQLite Database Browser to locate it, without luck. From the following question:
How to view the data in sqlite file running in iphone application?
I can see that the file should be located somewhere in this folder:
user/Library/Application Support/iPhone Simulator/
But the iPhone Simulator folder does not exist.
How do i make the simulator save the database to a local file?
Each time you run your application on simulator, it creates a folder inside iphone simulator folder .Make sure your Library folder is visible and you are using the correct path.
To make library folder visible you can run the following command on terminal:
Here`s the path for my iphone simulator folder to use as a reference:
/Users/alexandreoliveira/Library/Application Support/iPhone Simulator
Another thing to notice, usually the sqlite database get saved inside documents folders: