This will be a long post but please do read until the end and help out. Thank you!
In continuation of my previous post, [Android Studio - Database file loaded in the wrong encoding: 'UTF-8' my app was working fine when I run it both on my phone & an emulator despite the encoding error.
However, I am facing new issues now and I would like to just clarify why.
Just a head's up, I am using DB Browser for SQLite & Android Studio (3.2.1). My phone is Samsung S7 Edge+ and the emulator I have used is Pixel 2 XL API 28 (Android 9, API 28).
. The new data are those titled, "IIDS" "FIDS" and "GMID". Notice the two phones screenshots, the actual phone screenshots stopped at "Passenger Terminal" and upon scrolling down further no new data are shown, but on the phone emulator, new data are shown.
Initially, I thought it could be the sizing issue so I minimized the text sizes accordingly but the issue persisted. I can't think of other possible causes.
As such, does anyone know what could cause this issue and how I can fix it? Any help is greatly appreciated!
The initial issue was due to the database already existing and thus that the copy from the assets folder is/was not done.
Delete the database (deleting the App's data or uninstalling the App) would result in the database then being copied from the assets folder.
However, you then encountered an issue with the version number. I believe that this was because the App had been changed to use database version 2 (actually from SQLite's point of view the user_version). Thus as the version isn't 1 (I suspect if it's 1 no version check is made, hence why not even having a version (as from the comments was the case)) then an attempt was made to check the DB's version resulting in a null pointer exception as there was no user_version set (perhaps a bug).
Basically you do not want to change the DB version from 1 if you are (when developing the App) re-introducing a changed database that is copied from the assets folder. Alternately you need to set the appropriate version using PRAGMA user_version=?
(where ? is the version number) in the database, using whatever tool you use, before copying the databse into the assets folder.
The only reason why you would increase the database version (android wise) is when you are wanting the onUpgrade
method to run.
Note assumptions have been made re checking the version number.
If you have released an App, then it could be far more complex to roll out a changed database as an asset.