0

I am using Loader for a query using CursorLoader and the appropriate parameters to derive values.

I am using a recyclerview to display data.

Without the use of IS NOT NULL in my SELECTION parameter, which is the same as a WHERE clause my recylerview shows 2 blank rows. When I add IS NOT NULL in my selection clause, one blank row is removed and one still remains.

below is my simple SELECTION CLAUSE

    String SELECTION = ContactsContract.CommonDataKinds.StructuredPostal.CITY + " IS NOT NULL ";

    switch (id) {
        case LOADER_ID:
            return new CursorLoader(
                    getContext(),
                    ContactsContract.CommonDataKinds.StructuredPostal.CONTENT_URI,
                    FROM_COLUMNS,
                    SELECTION ,
                    null,
                    ContactsContract.CommonDataKinds.StructuredPostal.CITY + " ASC"
            );
NVA
  • 1,662
  • 5
  • 17
  • 24
  • Is it really a null value and not just an empty string? (i.e. '') – Sam Apr 19 '19 at 04:15
  • good question. It is being read as null by other methods that process the field. If there are other ways to check for NULL in SQL than I can add them as OR clause to the SELECTION. – NVA Apr 19 '19 at 04:18

1 Answers1

0

I used "<> ''" instead of IS NOT NULL

NVA
  • 1,662
  • 5
  • 17
  • 24
  • There are some systems that read the query to a file before loading, and in those cases nulls get encoded as an empty string. – Sam Apr 19 '19 at 14:09