Random exception android.database.sqlite.SQLiteException: unable to open database file

后端 未结 7 597
孤街浪徒
孤街浪徒 2020-12-14 07:59

My app uses a uncaught exception handler that sends the stack trace to me when the app crashes. Often I get this report from random users.

I cannot replicate it, th

7条回答
  •  忘掉有多难
    2020-12-14 08:26

    I have faced this issue.

    One of my applications was behaving in the same way, because I added the code to copy database from assets to specified location on the splash screen (the screen which is visible when app launches and automatically goes off the view after few seconds).

    And what was happening in few cases, that database was not getting copied in the specified time frame and accessing it from within the app was causing exceptions.

    What I did,

    I just wrote the code to copy database on background thread and show the splash screen to the user till the time database is not copied only after that show the next screen.

    There could be another solution in case, if the app is being installed on previous version, write the code to copy the saved data from previous version of app to new vesrion if data prevention is necessary and new version contains different models than that of previous version.

提交回复
热议问题