Quantcast
Channel: SQLite: db.insert not functioning inside an if statement - Stack Overflow
Browsing index pages (3 articles)

SQLite: db.insert not functioning inside an if statement

I am trying to use a SQLite database to store information for a recycler view. I would like the database to contain only unique records according to their description. I have tried to set the...

View Article


Answer by The Badak for SQLite: db.insert not functioning inside an if statement

there's no item description in the tempItem variable.Item tempItem = new Item(tempMenu.getFoodName(),tempMenu.getFoodCode(),tempMenu.getFoodPrice());so item.getDescription() must be null or emptylog...

View Article


Answer by Md. Asaduzzaman for SQLite: db.insert not functioning inside an if...

You are trying to execute operation on a closed DB instance. Try moving SQLiteDatabase db = getWritableDatabase(); inside if statements.if(!hasObject(item.getDescription())){ //Insert the row...

View Article
Browsing index pages (3 articles)


Latest Images