My App has a List-view to display values from an SQLite DB. There is an edit-text on the of the listview for searching for values in the List-view. Here is some of my code:
public void onTextChanged(CharSequence s, int start, int before,int count) {
String sCondition = "C_Data like '%" + ed.getText() + "%'";
Cursor data = database.query("tbl_Contents", fields, sCondition, null, null, null, "C_Data");
dataSource = new SimpleCursorAdapter(items_list.this, R.layout.row, data, fields, new int[] { R.id.first});
lv1.setAdapter(dataSource);
}
I have tested it out and it seems to work fine but I’m worried about performance because that code need to access on the database every time the user presses a key.
Without using an explicit search button how can I improve the performance of the search?
One thing I can think of is, while populating your listview populate a list (with just the field you require). So you can search the list than hitting the DB.