I'm using filtering and the only filter that is implemented is a search by key_name, I'd like to also add other keys.
public static Cursor fetchCountriesByName(String inputText) throws SQLException {
Log.w(TAG, inputText);
Cursor c = null;
if (inputText == null || inputText.length () == 0) {
c = db.query(DATABASE_TABLE, new String[] {KEY_ROWID,
KEY_NAME, KEY_COUNTRY, KEY_REGION, KEY_PHONE},
null, null, null, null, null);
}
else {
c = db.query(true, DATABASE_TABLE, new String[] {KEY_ROWID,
KEY_NAME, KEY_COUNTRY, KEY_REGION, KEY_PHONE},
KEY_NAME + " like '%" + inputText + "%'", null,
null, null, null, null);
}
if (c != null) {
c.moveToFirst();
}
return c;
}
when i tried to use else { if ( it requested a (c != null), when i tried to modify, KEY_NAME + " like '%" + inputText + "%'", null, KEY_COUNTRY + " like '%" + inputText + "%'",KEY_REGION + " like '%" + inputText + "%'"); was saying illegalargumentexception.
How to do it right?
Thanks.
Aucun commentaire:
Enregistrer un commentaire