I have a SQLite .db file that I want to access through sqflite on Flutter. Where in the Flutter project am I supposed to put it so that I can access it both on Android and iOS? How do I make sure that it's shipped with the apk? All examples that I found assume that the db needs to be created from scratch at the first launch.
The SQLite DLL file can be placed on Windows in C:WINDOWSsystem32 folder if needed to manage your database files.
sqflite | Flutter Package Inside the onCreate property, we can build our database table using execute method. To insert the data or model inside the database we use the insert method. It takes a table name and JSON value. To fetch the data from the database we use the query method.
Connect to the SQLite DB this tool will be there inside the platform-tools folder in your android SDK path. SDK path will be shown in android studio > sdk manager. Now navigate inside the sdk location and then inside the platform-tools folder. where you could see adb.exe.
You can put the db file in your assets folder and declare it in your pubspec.yaml. On startup you can write it out to disk and then use that path with your connection string to connect the db.
You can read from assets using
var dbContent =
await rootBundle.load('assets/database/mydb.db');
Then write it out to your file system and go from there.
I've found that this problem is related to:
https://stackoverflow.com/a/51387985/3902715
Credits to R. C. Howell
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With