在Flutter中使用新版本更新(本机)Android应用程序,同时保留数据库 [英] Update an (native) android app with a new version in Flutter while keeping the database

查看:59
本文介绍了在Flutter中使用新版本更新(本机)Android应用程序,同时保留数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用Java编写的android小型应用程序,我正在使用Flutter进行重写.

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

是否可以通过保持完整的SQLite数据库结构(包括所有数据)来过渡到新版本?

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.

推荐答案

如果有人需要它,我能够从现有数据库中读取数据并使用flutter对其进行写入.

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.

在Java中,我使用 SQLiteOpenHelper 类创建了数据库,而在新的flutter应用程序中,我尝试使用 getApplicationDocumentsDirectory()进行连接.

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 databasePath =等待getDatabasesPath();字符串路径=连接(databasesPath,"database.db");

这篇关于在Flutter中使用新版本更新(本机)Android应用程序,同时保留数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆