Skip to content

Instantly share code, notes, and snippets.

@lukaspili
Created July 4, 2012 10:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukaspili/3046525 to your computer and use it in GitHub Desktop.
Save lukaspili/3046525 to your computer and use it in GitHub Desktop.
SQLite query example
SQLiteDatabase db = databaseHelper.getReadableDatabase();
String[] columns = { "id", "strquote", "rating", "creation_date" };
Cursor cursor = db.query("quotes", columns, null, null, null, null,
null);
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
Quote quote = new Quote(cursor.getLong(0), cursor.getString(1),
cursor.getInt(2), null);
Date date = new Date(cursor.getLong(3));
quote.setDate(date);
quotes.add(quote);
cursor.moveToNext();
}
db.close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment