What I am trying to do is populate one listview, from two different tables in my database. The tables that I am using are:
--------------------------
|UNIT_TABLE|SHOVEL_TABLE |
|ID |ID |
|SITE_NAME |SITE_NAME |
|UNIT_NAME |SHOVEL_NAME |
--------------------------
The id is used in all my tables, as a basic autoincrement not null, the SITE_NAME is the name of the where the UNIT_TABLE and SHOVEL_TABLE are being completed at.
After some research on the best option I decided to use the following code to create a join on the two tables using the SITE_NAME to determine which ones I need.
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
String[] queries=new String[]{"select "+ID+", "+SHOVEL_NAME+" from "+SHOVEL_TABLE+" where "+SITE_NAME+"='"+Site+"'",
"select "+ID+", "+ UNIT_NAME+" from "+UNIT_TABLE+" where "+SITE_NAME+"='"+Site+"'"};
String SQL= qb.buildUnionQuery(queries, null, null);
This allowed me to combine all the data into one table, and populate my listview using a SimpleCursorAdapter. However, when I click on a list item, it takes me to the same activity. What I need it to do is if the item came from the SHOVEL_TABLE to go one Shovel.class, and if it came from the UNIT_TABLE I need it to go Unit.class.
Looking for any suggestions.