Using ListView and filtering SQLite database using editText
<p>I want to be able to filter a database using a list view. I want to be able to do this using an editText and using the SQL Like operator to filter the list. I have create a database helper class... </p>

<pre><code>package pkg.CookBook;

    import android.database.sqlite.SQLiteDatabase;
    import android.database.sqlite.SQLiteOpenHelper;
    import android.content.Context;


    public class DatabaseOpenHelper  {


        private static final String KEY_ROWID = "_id";
        private static final String KEY_NAME = "Recipe_Name";
        private static final String KEY_CATEGORY = "Recipe_Category";
        private static final String KEY_DESCRIPTION = "Recipe_Description";
        private static final String FOREIGN_ROWID2 = "Ing_Recipe_ID";
        private static final String KEY_ROWID2 = "Ing_id";
        private static final String KEY_NAME2 = "Ingredient_Name";
        private static final String KEY_CATEGORY2 = "Ingredient_Category";
        private static final String DATABASE_NAME = "database";
        private static final String DATABASE_TABLE = "CBRecipeData";

        private static final String DATABASE_TABLE2 = "CBIngredientData";

        private final Context myContext;
        private databaseHelper myHelper;
        private SQLiteDatabase myDatabase;

        public static class databaseHelper extends SQLiteOpenHelper{


            public databaseHelper(Context context){
                super(context, DATABASE_NAME, null,1);
            }

        // Database creation sql statement
        /*private static final String DATABASE_CREATE = "create table CBRecipeData      (recipe_id integer primary key autoincrement, "
                + "recipe category  text not null, recipe name text not null, recipe description text not null);";
        private static final String DATABASE_CREATE2 = "create table CBIngredientData (ing_recipe_id foreign key reference CBRecipeData recipe_id " + "integer ingredient_id integer primary key autoincrement, "
                + "recipe category  text not null, recipe name text not null, recipe description text not null);";

        */

        @Override
        public void onCreate(SQLiteDatabase database) {
            database.execSQL("Create Table"+ DATABASE_TABLE + " (" +
        KEY_ROWID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + 
        KEY_NAME + " TEXT NOT NULL, " +
        KEY_CATEGORY + " TEXT NOT NULL, " +
        KEY_DESCRIPTION + "TEXT NOT NULL");

        database.execSQL("Create Table"+ DATABASE_TABLE2 + " (" +
                    FOREIGN_ROWID2 + "foreign key reference CBRecipeData recipe_id, " +
                    KEY_ROWID2 + " INTEGER PRIMARY KEY AUTOINCREMENT, " + 
                    KEY_NAME2 + " TEXT NOT NULL, " +
                    KEY_CATEGORY2 + " TEXT NOT NULL");

        }

@Override
public void onUpgrade(SQLiteDatabase database, int oldversion, int newVersion)  {

    database.execSQL("Drop Table If Exists " + DATABASE_TABLE);
    onCreate(database);

}
        }

public DatabaseOpenHelper(Context c ){

    myContext = c;
}


public DatabaseOpenHelper open(){

    myHelper = new databaseHelper(myContext);
    myDatabase = myHelper.getWritableDatabase();
    return this;
}

public void close(){
    myHelper.close();
}

public void createEntry(String Name, String Description, String Category){

}
    }


.... 
</code></pre>

<p>I am confused however as to how I can filter the database and how to actually display this in a list view.. </p>

<pre><code>String query = "SELECT _id, Recipe_Name "+
            "FROM CBRecipeData "+
            "WHERE Recipe_name Like %" + filterText.getText().toString() + "%" +
            "ORDER BY Recipe_Name";


            final Cursor c = dbHelper.getReadableDatabase().rawQuery(query,     null);
</code></pre>

<p>I know that this is like the filter that I want to implement but how to use this with a list view is the problem.. </p>

<p>Any pointers to the right direction would be great!!! :) 
thanks stef</p>
