/ Published in: Java
search a string inside the database an post the results into a ListView
Expand |
Embed | Plain Text
//in the dbHelper SQLiteDatabase db = getReadableDatabase(); Cursor cursor = db.rawQuery(" SELECT _id FROM "+Vals.PAGES_TABLE_NAME+" WHERE content LIKE '%"+str+"%'", null); return cursor; } //in the search activity int[] to; to = new int[]{R.id.listCellTextView}; @SuppressWarnings("deprecation") SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.list_cell, db.searchStr(str), from, to); listView.setAdapter(adapter); listView.setOnItemClickListener(this); }
You need to login to post a comment.
