My app is a menu and winelist in the restaurant. I frequently update the database during business hours using push notification and httputils. 99% of the time all the tablets update successfully, but occasionally, after sending update message, one of them will crash with this error:
When I go into file manager to look at the .db file, it is much smaller than it should be. I am indeed using the HttpUtils.IsSuccess before overwriting the old DB with the newly downloaded one. I am also closing the database prior to the overwrite. When this occurs, I have tried sending another "download new database" push message to that particular device, but is does not resolve the problem. I end up having to email a copy of the database and manually copy it to the proper location.
My plan is add a try/catch block when initializing the database, and if an error is detected, copy a "backup" database instead. I will then add code to download a fresh copy of the db from the server.
My ultimate question is why might this be happening? At one point, I thought that if someone was interacting with the app during the database overwrite, this could cause a problem. I was told though that everything is happening in the main thread so that should not be an issue.
B4X:
android.database.sqlite.SQLiteDatabaseCorruptException: database disk image is malformed: , while compiling: PRAGMA journal_mode=TRUNCATE
When I go into file manager to look at the .db file, it is much smaller than it should be. I am indeed using the HttpUtils.IsSuccess before overwriting the old DB with the newly downloaded one. I am also closing the database prior to the overwrite. When this occurs, I have tried sending another "download new database" push message to that particular device, but is does not resolve the problem. I end up having to email a copy of the database and manually copy it to the proper location.
My plan is add a try/catch block when initializing the database, and if an error is detected, copy a "backup" database instead. I will then add code to download a fresh copy of the db from the server.
My ultimate question is why might this be happening? At one point, I thought that if someone was interacting with the app during the database overwrite, this could cause a problem. I was told though that everything is happening in the main thread so that should not be an issue.