Skip to content
Advertisement

Why do I fail to save data in my application?

I am a student and started working on android studio recently. I don’t know about it much. I am working on an application where I save the item name and its amount in the database and display toast message if data we entered is saved or not. problem is whenever I click on the save button my application crashes.

following is my DatabaseHelper class:

following is my MainActivity class:

I will appreciate your help. Thank you

Advertisement

Answer

It might be crashing because it’s not creating the table:

A space is missing between table and its name:

You should also close the database after you get the data in db.insert but this only creates a warning:

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement