my listview is happening correctly its fetching from sqlite database. but my problem is i have added edittext to filter by name . so if i enter any letter in my edittext it should filter accordingly. but its not happening . Below is my code.
MainActivity.java
public void afterTextChanged(Editable arg0) {
// TODO Auto-generated method stub
ArrayList<StudentEntity> listentity = new ArrayList<StudentEntity>();
String texto="";
texto=inputSearch.getText().toString();
String DB_PATH = "/data/data/com.naman.namrathasrinivas.choultriesbangalore" + "/databases/";
String DB_NAME = "Marriage.sqlite";
String mypath = DB_PATH + DB_NAME;
db = SQLiteDatabase.openDatabase(mypath, null,
SQLiteDatabase.OPEN_READWRITE);
String selectQuery = "SELECT * FROM hall WHERE name LIKE '%\" + texto + \"%' ";
Cursor cursor = db.rawQuery(selectQuery, null);
if (cursor.moveToFirst()) {
do {
StudentEntity sentity = new StudentEntity();
sentity.setName(cursor.getString(1));
sentity.setLocality(cursor.getString(12));
listentity.add(sentity);
} while (cursor.moveToNext());
}
}
Aucun commentaire:
Enregistrer un commentaire