I am trying to make query from DB in the following way
public Cursor getManagementData() { String selectQuery = "SELECT * FROM " + DBHelper.TABLE_STAFF + " WHERE " + DBHelper.COLUMN_DEPARTMENT + " GLOB " + "'management'"; return db.rawQuery(selectQuery, null); } The same thing I have tried with
query(DBHelper.TABLE_STAFF, new String[] { DBHelper.COLUMN_ID, DBHelper.COLUMN_NAME, DBHelper.COLUMN_LAST_NAME, DBHelper.COLUMN_POSITION, DBHelper.COLUMN_DEPARTMENT, DBHelper.COLUMN_PICTURE }, null, new String[] { "management" }, null, null, null); but nothing happens.
The table structure is very simple: Table staff with Column department and I want to get all entries named management.
If you will not be able to answer, please recommend where to find close solution because after googling I have not found any comprehensive examples on searching DB by entries whether with rawQuery or just query.
Thank you in advance.
I have made changes recomended by Mr.Choy it does not crashes but when open in my app list is empty. At the same time when I run the following query:
public Cursor getEmployeesData() { return db.query(DBHelper.TABLE_STAFF, new String[] { DBHelper.COLUMN_ID, DBHelper.COLUMN_NAME, DBHelper.COLUMN_LAST_NAME, DBHelper.COLUMN_POSITION, DBHelper.COLUMN_DEPARTMENT, DBHelper.COLUMN_PICTURE }, null, null, null, null, null); } it shows all data as it should be.
Could it be the problem with cursor adapter def. I use:
String[] from = new String[] { DBHelper.COLUMN_NAME, DBHelper.COLUMN_LAST_NAME, DBHelper.COLUMN_POSITION, DBHelper.COLUMN_DEPARTMENT, DBHelper.COLUMN_PICTURE }; int[] to = new int[] { R.id.textView1, R.id.textView2, R.id.textView3, R.id.textView4, R.id.imageView1 };