0

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.

learning_fly
  • 382
  • 1
  • 2
  • 11
  • if(r.getString(k) != null){ grid.insert(new LabelField(r.getString(k)) } – Yaqub Ahmad May 07 '12 at 16:57
  • The above code ignores the record with null value.Gives a run time error of data type mismatch.No stack trace.I would like to fetch all values including the null.Exactly as it is in the original table. – learning_fly May 07 '12 at 17:08

1 Answers1

1

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.

Michael Donohue
  • 11,776
  • 5
  • 31
  • 44