Skip to content

Instantly share code, notes, and snippets.

@bmadigan
Created June 28, 2010 15:57
Show Gist options
  • Save bmadigan/456004 to your computer and use it in GitHub Desktop.
Save bmadigan/456004 to your computer and use it in GitHub Desktop.
var adp = Titanium.API.Application.getDataPath();
var dbpath = adp+"\\"+"sampledb.db";
var db = Titanium.Database.openFile(dbpath);
db.execute('CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, firstname VARCHAR(50), lastname VARCHAR(50))');
var firstname = $("input#firstname").val();
var lastname = $("input#lastname").val();
db.execute("INSERT INTO users (firstname, lastname) VALUES (?, ?)", firstname, lastname);
alert("Added the User: " + firstname + " " + lastname);
db.close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment