Skip to content

Instantly share code, notes, and snippets.

@sax1johno
Last active August 29, 2015 14:21
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 sax1johno/34656c0155b3334fbf2b to your computer and use it in GitHub Desktop.
Save sax1johno/34656c0155b3334fbf2b to your computer and use it in GitHub Desktop.
public Cursor fetchRow (SQLiteDatabase readOnlyDatabase, long rowId, boolean archived, boolean isFavorite, String title) {
StringBuilder sqlStatement = new StringBuilder();
sqlStatement.append("SELECT * FROM " + COLUMN_RSS_FEED + " WHERE rowId = " + rowId);
if (archived != null) {
sqlStatement.append(" AND " + COLUMN_ARCHIVED + " = " + archived);
}
if (isFavorite) {
sqlStatement.append(" AND " + COLUMN_FAVORITE + " = " + isFavorite);
}
if (title) {
sqlStatement.append(" AND " + COLUMN_TITLE + " = " + title);
}
sqlStatement.append(";");
return readOnlyDatabase.rawQuery(sqlStatement.toString());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment