mercredi 1 avril 2015

search an array in sqlite table

i have one table like this:



database.execSQL("CREATE TABLE IF NOT EXISTS food_table (food_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL , food_name CHAR, food_raw CHAR)");


and i have an String array like this:



public static ArrayList<String> rawsNames = new ArrayList<String>();


now i want to search in my table and if all of raw of food were in rawsNames return the food_name .


i do this :



String raws = AdapterNotes.rawsNames.toString().replace("]", "").replace("[", "");
Cursor cursor = G.database.rawQuery("select * from food_table WHERE food_raw LIKE '%" + raws + "%' ", null);
while (cursor.moveToNext()) {
String name = cursor.getString(cursor.getColumnIndex("food_name"));


But when the food's raw is changed it doesn't work.


please help me.


Aucun commentaire:

Enregistrer un commentaire