Skip to content

Instantly share code, notes, and snippets.

@winterlightning
Created August 19, 2011 16:27
Show Gist options
  • Save winterlightning/1157259 to your computer and use it in GitHub Desktop.
Save winterlightning/1157259 to your computer and use it in GitHub Desktop.
Simple db calls to mimic localstorage. Fix for titanium bug
db_path = Titanium.Filesystem.getFile(Titanium.Filesystem.getApplicationDataDirectory(), 'gtasktic.db');
db = Titanium.Database.openFile( db_path );
db.execute("CREATE TABLE IF NOT EXISTS keyval ( key TEXT, value TEXT )");
//Insert
db.execute("INSERT INTO keyval (key, value) VALUES ('" +this.name +"', '"+ result +"')");
//Read
var resultSet = db.execute("SELECT value FROM keyval WHERE key = '"+ this.name +"' LIMIT 1");
result = resultSet.field(0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment