简体   繁体   English

使用预建数据库升级Android App

[英]Upgrading Android App with pre-built database

I have an Android App with a pre-built SQLite DB packaged with it. 我有一个带有预打包SQLite DB的Android应用。 However, I'm sure that if I want to do an upgrade with an upgraded/altered/new database it will be tricky. 但是,我确定,如果要使用已升级/已更改/新的数据库进行升级,将非常棘手。 I found this out on my emulator and handset. 我在模拟器和手机上发现了这一点。 When I changed DBs (keeping the name the same, or altered the DB and put it back into the assets directory, and then ran the app on the emulator, it wouldn't read the new DB, but would keep the old database. The only way to get rid of the old DB, it seems, is to delete the app and reinstall it. WHich is what I do when I test my apps on my handset after changing the database. Another option is to change the name of the database, and all references to it in the code, but this doubles the database storage of the app and wastes space. 当我更改数据库(保持名称不变,或更改数据库并将其放回资产目录中,然后在模拟器上运行该应用程序时,它不会读取新的数据库,但会保留旧的数据库。)摆脱旧数据库的唯一方法似乎是删除应用程序并重新安装它,这是在更改数据库后在手机上测试应用程序时要做的事情。另一种选择是更改数据库名称,以及代码中对其的所有引用,但这会使应用程序的数据库存储量增加一倍,并且浪费空间。

Take a look at SQLiteOpenHelper - it will help you maintain the DB within your app. 看一下SQLiteOpenHelper-它可以帮助您维护应用程序中的数据库。

http://www.devx.com/wireless/Article/40842 http://www.devx.com/wireless/Article/40842

It also has a database version property which you can increment, and it wipes the DB and recreates it. 它还具有您可以增加的数据库版本属性,并且擦除了数据库并重新创建它。 It also allows you to update your database easily, without affecting user data (if you plan on doing future updates to your app). 它还使您可以轻松地更新数据库,而不会影响用户数据(如果您打算将来对应用程序进行更新)。

I think this is what you're looking for. 我认为这就是您要寻找的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将预建的Java类包含到android项目中 - including pre-built java classes into an android project 以预建字典作为数据结构的压缩算法 - Compression algorithm operating on pre-built dictionary as data structure Github Service Hooks:自动配置预建集成信息 - Github Service Hooks: auto config pre-built integrations information 是否有用于通用Java接口的预构建JUnit测试存储库? - Is there a repository of pre-built JUnit tests for common Java Interfaces? 将返回箭头添加到预建的 FirebaseUI 登录? - Add back arrow to pre-built FirebaseUI Sign-in? Android从预建的SQLite数据库获取数据 - Android Getting data from pre built SQLite Database spark下载页面上预建和用户提供的hadoop有什么区别? - What are the differences between pre-built and user-provided hadoop on spark download page? 编写Java程序以使用预构建的界面(“生活”游戏)运行,但是我遇到了麻烦 - Writing a Java program to run with a pre-built interface (the Life game) but I'm having trouble 像(check_load)这样的典型预构建Nagios插件的源代码是什么? - What is the source code of a typical pre-built Nagios Plugin like (check_load)? Gradle在Jenkins中构建JaCoCo jacocoTestReport时排除预构建的jar和类 - Gradle Exclude pre-built jars and classes while building JaCoCo jacocoTestReport in Jenkins
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM