SQLiteException not being caught

后端 未结 4 1798
自闭症患者
自闭症患者 2021-01-19 22:56

I\'m trying to catch an \"android.database.sqlite.SQLiteException: error code 5: database is locked\" exception with:

    try {
        db.insert(\"mytable\"         


        
4条回答
  •  一生所求
    2021-01-19 23:40

    If that catch block is failing to catch the exception then either it isn't being thrown inside that particular try block, or you've got the wrong exception. The fact that it still doesn't work if you catch Exception says that it is the former problem.

    So you need to find out where the exception is really being throw. I'd try changing the logging configurations to get LogCat to log full exception stacktrace. That should tell you where it was thrown. If you can't do that, then you'll need to find this using a debugger ... or by trawling through your applications source code to find where the exception is being logged.

    (The other possibility is that the catch block is catching the exception, but you've got your logging configs set up to discard "debug" log events.)

提交回复
热议问题