TodoList 클래스

--------------------------------------------------------------------------------------------------

public class TodoList {
 public TodoList(Activity AActivity){
  super();

  _Activity=AActivity;
  _DB= _Activity.openOrCreateDatabase("food.db",_Activity.MODE_PRIVATE, null);

  Adapter= new SimpleAdapter(
    _Activity, _Datasource, android.R.layout.simple_list_item_2,
    new String[]{"food_name","calorie"},
    new int[] {android.R.id.text1, android.R.id.text2} );
  Refresh();
 }
 public void Append(String ATitle){

  HashMap<String,String>_Item= new HashMap<String,String>();
  _Item.put("food_name", Integer.toString(0));
  _Item.put("calorie", Integer.toString(0));
 }
 public void Refresh(){
  Cursor _Cursor=_DB.rawQuery("Select*from foodlist ",null);
  if(_Cursor.moveToFirst()){
   do{
    HashMap<String,String>_Item= new HashMap<String,String>();
    _Item.put("food_name",_Cursor.getString(1).toString());
    _Item.put("calorie",_Cursor.getString(2).toString());
    _Datasource.add(_Item);
   }while (_Cursor.moveToNext());
  }
  Adapter.notifyDataSetChanged();
 }
 public BaseAdapter Adapter=null;
 private ArrayList<HashMap<String,String>> _Datasource=
  new ArrayList<HashMap<String,String>>();

 private SQLiteDatabase _DB=null;
 private Activity _Activity=null;
}

-----------------------------------------------------------------------------------------

public class main extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        String dir="data/data/ex.aaa/";
  String db_name="food.db";
  File folder = new File(dir+"databases");
  folder.mkdirs();
  File outfile = new File(dir+"databases/"+db_name);
  if(outfile.length() <= 0) {
  AssetManager assetManager = getResources().getAssets();
  try {
  InputStream is = assetManager.open(db_name, AssetManager.ACCESS_BUFFER);
  long filesize = is.available();
  byte[] tempdata = new byte[(int)filesize];
  is.read(tempdata);
  is.close();
  outfile.createNewFile();
  FileOutputStream fo = new FileOutputStream(outfile);
  fo.write(tempdata);
  fo.close();
  } catch (IOException e) {
  e.printStackTrace();
  }
  }
      
        _TodoList=new TodoList(this);
        _edTitle=(EditText) findViewById(R.id.editText1);
        _edTitle.setOnKeyListener(on_KeyEvent);
        _ListView=(ListView) findViewById(R.id.listView1);
        _ListView.setAdapter(_TodoList.Adapter);
        }
        private TodoList _TodoList=null;
        private EditText _edTitle=null;
  private ListView _ListView=null;
  private View.OnKeyListener on_KeyEvent= new View.OnKeyListener() {
   
   @Override
   public boolean onKey(View v, int keyCode, KeyEvent event) {
    if(event.getAction()==KeyEvent.ACTION_DOWN){
     if(keyCode==KeyEvent.KEYCODE_ENTER){
    _TodoList.Append(_edTitle.getText().toString());
    _edTitle.setText("");
    return true;
    }
   }
 return false;
   
}
};
}

-----------------------------------------------------------------------------------------

123.jpg

이런식으로 db 불러오기는 했습니다.

 

여기에 검색창을 넣어주고 싶습니다.

 

어떻게 해야하나요... 도와주세요..