Sorry for my english. I try create dynamicly serch. Example: we input serch word hellow, i input h-> he is serch all word who name start in latter he-> he is serch all word who name start in latter hel-> he is serch... and so on. The word may be upper and lower case like this HeLLow. My example
public List<Map<String, String>> getSearch(String tableName, String search) {
String query = "SELECT * FROM " + tableName + " WHERE `name` LIKE " + search;
Cursor cursor = db.rawQuery(query, null);
List<Map<String, String>> list = new ArrayList<>();
String[] names = cursor.getColumnNames();
if(cursor.moveToFirst()) {
do{
Map<String, String> map = new HashMap<String, String>();
for (int i = 0; i < names.length; i++) {
map.put(names[i], cursor.getString(i));
}
list.add(map);
} while (cursor.moveToNext());
}
return list;
}
I try do like this:
String query = "SELECT * FROM " + tableName + " WHERE name = " + search;
String query = "SELECT * FROM " + tableName + " WHERE name MATCH " + search;
its not work too, i have always list = 0
Aucun commentaire:
Enregistrer un commentaire