I want to filter category and word in query method. and now i make query filler word matching. This is SQL code
@Override
public List<Word> getWordListMatchingInCategoryInternet(String matching) {
String TABLE = Util.getTableName();
String[] FIELD = new String[]{DictionaryDatabase.COLUMN_ID, DictionaryDatabase.COLUMN_WORD, DictionaryDatabase.COLUMN_MEAN, DictionaryDatabase.COLUMN_FAVORITE,DictionaryDatabase.COLUMN_PIC,DictionaryDatabase.COLUMN_CATEGORY,DictionaryDatabase.COLUMN_HISTORY};
String WHERE = DictionaryDatabase.COLUMN_WORD +" LIKE ?" ;
String[] WHERE_ARGS = new String[]{matching + "%"};
String ORDER_BY = DictionaryDatabase.COLUMN_WORD + " COLLATE NOCASE ASC" ;
Cursor cursor = sqLiteDatabase.query(TABLE,FIELD,
WHERE,WHERE_ARGS,null,null,ORDER_BY );
List<Word> wordList = new ArrayList<Word>();
int idColumnIndex = cursor.getColumnIndex(DictionaryDatabase.COLUMN_ID);
int wordColumnIndex = cursor.getColumnIndex(DictionaryDatabase.COLUMN_WORD);
int meanColumnIndex = cursor.getColumnIndex(DictionaryDatabase.COLUMN_MEAN);
int favoriteColumnIndex = cursor.getColumnIndex(DictionaryDatabase.COLUMN_FAVORITE);
int categoryColumnIndex = cursor.getColumnIndex(DictionaryDatabase.COLUMN_CATEGORY);
int picColumnIndex = cursor.getColumnIndex(DictionaryDatabase.COLUMN_PIC);
int historyColumnIndex = cursor.getColumnIndex(DictionaryDatabase.COLUMN_HISTORY);
while (cursor.moveToNext()){
Word word = new Word(cursor.getInt(idColumnIndex),cursor.getString(wordColumnIndex), cursor.getString(meanColumnIndex), cursor.getInt(favoriteColumnIndex)==1,cursor.getBlob(picColumnIndex),cursor.getString(categoryColumnIndex),cursor.getInt(historyColumnIndex)==1);
wordList.add(word);
}
return wordList;
}
I want to filter category with word mathching . What will I do? by DictionaryDatabase.COLUMN_CATEGORY = "internet"
Aucun commentaire:
Enregistrer un commentaire