I have a db with 10 tables and each with 5 to 10 columns and am expecting not more than 500 records for the whole db.
I want to implement a search feature in the app where I search the whole db for a keyword and display a custom listview for all the results.
I tried searching for ways to implement this but haven't found a solution for SQLite in android. There are SQL server implementations of this.
The way I see it at the moment is to write a query for every table and search every column and then filter the result to populate my custom listview.
public Cursor searchDB(String query) {
return db.query(true, DB_TABLE,
new String[] { KEY_ROWID, KEY_COLUMN1, KEY_COLUMN2, ... KEY_COLUMN10},
KEY_COLUMN1 + " LIKE" + "'%" + query + "%' OR " +
KEY_COLUMN2 + " LIKE" + "'%" + query + "%' OR " + ...
KEY_COLUMN10 + " LIKE" + "'%" + query + "%'",
null, null, null, null, null);
}
Appreciate opinions on this matter and any help with implementation.