how can I access columns with the same name? I have tried doing cursor.getString(cursor.getColumnIndexOrThrow("table.column"))
but it doesn't seem to work
You can use aliases, i.e.
db.rawQuery("SELECT column1 AS c1 FROM table");
Then you can use:
cursor.getColumnIndex("c1");
Obviously same applies for fields from JOINs. Cheers.
EDIT
Example with join clause:
db.rawQuery("SELECT t1.columnX AS c1, t2.columnY as c2 FROM table1 t1 INNER JOIN table2 t2 ON t1.A = t2.B");
Then you can simply use the alias name regardless of the table it belongs to:
cursor.getColumnIndex("c2") should return 1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With