Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update an (native) android app with a new version in Flutter while keeping the database

I have a small application for android written in java, I am rewriting using flutter.

Is it possible to transition to the new version by keeping the SQLite database structure intact, including all data?

I ran a test, and although I was able to overwrite the application, the data was lost after upgrade.

like image 864
tbruning Avatar asked Oct 16 '22 13:10

tbruning


1 Answers

If anyone needed it, I was able to read the data from the existing database and write to it using flutter.

My previous test had gone wrong because the bases were allocated in separate directories.

In java, I had created the database using the SQLiteOpenHelper class, while in the new flutter application I tried to connect using getApplicationDocumentsDirectory().

I just changed the access path, and it's all settled :)

var databasesPath = await getDatabasesPath (); String path = join (databasesPath, "database.db");

like image 175
tbruning Avatar answered Oct 21 '22 01:10

tbruning