reset password
Author Message
ngosrani
Posts: 31
Posted 21:59 May 18, 2016 |

Hi Professor,

I did write the create query in DbHelper class and also insert query in DatabaseTest class but I cannot see the table getting created nor any inserts being performed when I cross checked running queries from command line. I am not sure how do I do this.

skim144
Posts: 63
Posted 22:16 May 18, 2016 |

I think you are missing this? 

sqLiteDatabase.execSQL(query)
ngosrani
Posts: 31
Posted 00:17 May 19, 2016 |

I have this line included too. But still it doesn't work.

msargent
Posts: 519
Posted 08:58 May 19, 2016 |

There are a lot of things that could cause this. Try an assertNot -1 on the long returned from your insert method. If this fails, then you are not inserting anything. Also, when viewing tables directly in the emulator, make sure you are in the right directory and you have opened the right database. 

Also, check that your tables are being created in the onCreate method. BTW, onCreate will only be called if there aren't any tables in your db. 

 

Last edited by msargent at 08:59 May 19, 2016.
skim144
Posts: 63
Posted 09:19 May 19, 2016 |

Or, it could be that your test method name doesn't start with the word "test".

Test method should start with the word "test", just like @Test annotation in JUnit (as explained in the video)