*
* @return A hash table of Category objects, one for each record in the
* Category table
*/
IntHashtable getCategories() {
final IntHashtable categories = new IntHashtable();
try {
// Read in all records from the Category table
final Statement statement =
_db.createStatement("SELECT * FROM Category");
statement.prepare();
final Cursor cursor = statement.getCursor();
Row row;
int id;
String name;
Category category;
// Iterate through the result set. For each row, create a new
// Category object and add it to the hash table.
while (cursor.next()) {
row = cursor.getRow();
id = row.getInteger(0);
name = row.getString(1);
category = new Category(id, name);
categories.put(id, category);
}
statement.close();
cursor.close();
} catch (final DatabaseException dbe) {
SQLiteDemo.errorDialog(dbe.toString());