如何找到sqlite database
中的確切數據並在listactivity
中檢索它?我嘗試這樣,但我沒有得到價值。從sqlite數據庫中搜索一個值,並在列表視圖中檢索
search = (EditText) findViewById(R.id.alertsearch);
search.addTextChangedListener(new TextWatcher(){
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
list2.clear();
db = openOrCreateDatabase(Contactsnew.DB_NAME, MODE_PRIVATE, null);
Cursor cTitle=db.rawQuery(" SELECT * FROM "+ Contactsnew.TABLE02 + " WHERE "
+ Contactsnew.userid + " = " + GetSet.getUserId() + " AND " + Contactsnew.TITLE +
" LIKE ? " ,new String []{search.getText()+"%"});
custAdapter.changeCursor(cTitle);
while(cTitle.moveToNext()){
list2.add(cTitle.getString(2));
}
cTitle.close();
}
試試這種方式:http://stackoverflow.com/a/1243378/1168654 –
什麼是Contactsnew? – 2014-06-30 09:08:25