Replies: 3 comments 1 reply
-
It could be because you are missing an await inside your Could you share it? |
Beta Was this translation helpful? Give feedback.
0 replies
-
Here you go, it's essentially unchanged from the example DatabaseHelper:
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Aaah, got it! Your question got me thinking down different lines. It wasn't not enough "await" lines, it was too many "async". If I remove async from the _onCreate, _onUpgrade, and _onDowngrade functions it works fine. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm having a problem with the way the database helpers initialize, create and update the database. Since these functions are making async calls to _onCreate or _onUpgrade, the get database method is returning the database object to the application before it's ready, which then results in "exception: no such table" errors.
If I make a manual call to "get database", and add a 500ms delay before allowing my application to initialize and read any data everything completes fine, but this is clearly not ideal, and from the database helper examples given I don't see any way to avoid this as the issue seems to be fundamentally linked to how openDatabase calls these functions. I consider myself an amateur coder, so I may be missing something here, but I don't see how this could be working for so many people without errors.
In essence, the "await _initDatabase();" line here does not wait for the database to complete an _onCreate or _onUpgrade action before returning:
In my application, if I add some print statements to show the flow, the initial opening of the database generates exceptions on create or upgrade, as the application flow is something like:
Beta Was this translation helpful? Give feedback.
All reactions