O'Reilly logo

Appcelerator Titanium Smartphone App Development Cookbook - Second Edition by Jason Kneen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Retrieving data from a SQLite database

The ability to create a table and insert data into it is not of much use if we don't know how to retrieve that data and present it in a useful way to the user! We'll now introduce the concept of resultSet (or recordSet, if you prefer) in SQLite and see how to retrieve data via this resultSet object, which can be collected and returned in an array format suitable for use within a TableView.

How to do it...

In your database.js file, add the following function under the db.deleteFavorite function:

db.getFavorites = function() { var sql = "SELECT * FROM favorites ORDER BY title ASC"; var results = []; var resultSet = db.database.execute(sql); while (resultSet.isValidRow()) { results.push({ id: resultSet.fieldByName('id'), ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required