Search code examples
sqliteblackberrynullblackberry-jde

How to retrieve data that contains null value for some field in sqlite?


I am fetching rows of record from my sqlite table for blackberry application.But certain fields contain a null and i get a run time error of No stack trace at those field.How i can i continue fetching data irrespective of their null fields. This is how my table looks

    Date        Bill  Receipt
    12/5/2012    50  
    16/4/2012    40    20
    1/6/2012     50    30

It gives me error for that third element of first row.

This is my code used for retrieving values

   grid.insert(new LabelField(r.getString(k))

continuously going through 3 for loops-one for row,one for column and one for each column of database table. If anyone aware on a solution to this,please share.Thanks.


Solution

  • Use Row.getObject() instead of Row.getString(). It will return 'null' for null values without throwing an exception. If non-null, you can then do a type check, or just cast to String if you know it will always be of type string.