samedi 31 janvier 2015

AutoCompleteView load data from database

In my android application I have a database of around 1000 rows of data in one table. I have an auto complete text view when user enters a key it hast to drop-down appropriate item from the db table how can I do this.


database fetching code



public Map<String, String> getSimilarStems(String stem) {
Map<String, String> results = new LinkedHashMap<String, String>();

Cursor res = db.rawQuery("SELECT word, _id FROM words_en WHERE stems LIKE '%"+stem+" %' OR stems LIKE '"+stem+"' ORDER BY LENGTH(word) LIMIT 10", null);

while(res.moveToNext()) {
String id = res.getString(res.getColumnIndex("_id"));
String word = res.getString(res.getColumnIndex("word"));
results.put(id, word);
}
return results;
}


please anyone help me to bind the data from the database with the AutoCompleteView


Aucun commentaire:

Enregistrer un commentaire