Skip to content

Instantly share code, notes, and snippets.

@thanhnh98
Last active February 2, 2020 12:50
Show Gist options
  • Save thanhnh98/410a9ac6746f89fee609104f56233ce6 to your computer and use it in GitHub Desktop.
Save thanhnh98/410a9ac6746f89fee609104f56233ce6 to your computer and use it in GitHub Desktop.
public Note getNote(int id) {
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.query(TABLE_NOTE, new String[] { COLUMN_NOTE_ID,
COLUMN_NOTE_TITLE, COLUMN_NOTE_CONTENT }, COLUMN_NOTE_ID + "=?",
new String[] { String.valueOf(id) }, null, null, null, null);
if (cursor != null)
cursor.moveToFirst();
Note note = new Note(Integer.parseInt(cursor.getString(0)),
cursor.getString(1), cursor.getString(2));
return note;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment