0

I currently have the query which selects the corresponding row with the given id

Cursor cursor = db.query(TABLE_MEMOS, new String[] { KEY_ID, KEY_TITLE,
                         KEY_BODY, KEY_IMPOR, KEY_ALERT }, KEY_ID + "=?",
                         new String[] { String.valueOf(id) }, null, null, null, null);

I need to cast the column KEY_ID name to _id for it to work with cursors but can't figure out where to add the AS command into the query.

ted
  • 13,596
  • 9
  • 65
  • 107
  • can you please checkout this link http://stackoverflow.com/questions/805363/how-do-i-rename-a-column-in-a-sqlite-database-table[enter link description here](http://stackoverflow.com/questions/805363/how-do-i-rename-a-column-in-a-sqlite-database-table) – Vadivel Nov 18 '16 at 04:47

1 Answers1

1

You can specify column aliases in the string array containing column names, e.g.

String[] cols = new String { KEY_ID + "AS _id", KEY_TITLE,
                             KEY_BODY, KEY_IMPOR, KEY_ALERT };
Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360