Android sqlite - select records where field is null or empty

android, sqlite

Solution

Try

cursor = db.query(DBHelper.TABLE_NAME, COLUMNS, "folder_name is null or folder_name = ?", new String[] {""}, null, null, DBHelper.TIMESTAMP_COL + " DESC");

Problem

My application has an sqlite DB, where some of the fields are null or empty (meaning that I never inserted anything into that field). I wish to select all the records for which the field is null or empty. This is what I have tried: ``` cursor = db.query(DBHelper.TABLE_NAME, COLUMNS, "folder_name = ? ", new String[] {"null"}, null, null, DBHelper.TIMESTAMP_COL + " DESC"); ``` But that didn't work, and I didn't get any records. What do I need to do to make this work?

Original source