2

My main goal is to import a database into a flutter app using sqlite(sqlflite plugin), instead of having to hard code all of the create tables into the apps code.

*I want the information to be accessed to the phone locally(access data from phone on airplane mode) that is why i am using sqlite

I am having trouble finding information on this online and was seeing if anyone had experience in doing this or has documentation/examples that could help.

Mfreeman
  • 3,548
  • 7
  • 23
  • 37

2 Answers2

1

i think you are looking for this : Open an asset database in this case you must have the database already and you don't need to create tables

Raouf Rahiche
  • 28,948
  • 10
  • 85
  • 77
  • I am having trouble quite understanding that, it seems this would be a fix for something that i wouldn't have to otherwise write myself, i do have a mysql database with everything written in it, but for the purposes of this app i need the database to connect to sqlite to persist the specific data i need from the database to the app. Im starting to think that may not be possible. – Mfreeman Jul 11 '18 at 16:45
  • 1
    you have a mysql and you want to import it to SQLITE ? – Raouf Rahiche Jul 11 '18 at 16:46
  • Yeah i do, i realize that i need to hardcode no matter what, unless i'm connecting remotely to a database which i don't want to do. Just need data to persist on the app permanently – Mfreeman Jul 11 '18 at 17:03
  • take a look at other choice like Firebase firestore or Realm you get this behaviour for free – Raouf Rahiche Jul 11 '18 at 17:05
  • 1
    Perfect, looks like they have offline persistence, thank you! – Mfreeman Jul 11 '18 at 17:08
  • yes also take a look at my answer to a similar [question](https://stackoverflow.com/questions/41369633/how-can-i-save-to-local-storage-using-flutter/50849802#50849802) – Raouf Rahiche Jul 11 '18 at 17:10
  • @Raouf Rahiche the link you provided no longer works, is there an updated link? I need this badly – Frank May 11 '19 at 17:40
0

Flutter supports an open source module SQFlite. SQFlite is a way of storing app data in Flutter Application. SQFlite is a Database plugin for flutter. It is highly reliable and embedded Database engine. All the CRUD operation in the database will run on a background thread. You can see a simple example of this here.

Sunil
  • 3,211
  • 3
  • 21
  • 21