Proper way of using sqlite insertOrThrow

Viewed 460

My code looks something like this:

ContentValues values = new ContentValues();
values.put("year", year);
values.put("month", month);
database.insert(MySQLiteHelper.TABLE_DATA, null, values);

Everything works fine, but unfortunately the insert query will always return -1 on one of my user's device. My app has bugsnag so now I changed the

insert

to

database.insertOrThrow

hoping that when an error occurs on the user's phone again, bugsnag will notify me. BUT just to make sure (since I've never used insertOrThrow before; usually just insert encapsulated in try catch), is the code above sufficient? When an error happens on insert, will bugsnag capture it? Maybe my question can be summarized as 'how do I handle throw in insertOrThrow?'

2 Answers

Make sure you are putting all the values that you have been declared during creating the table in my case that solve the problem.

Related