如何升级新表和现有应用程序?
朋友,
我已经发布了一个现有的应用程序,在升级过程中,我想向我的数据库添加一个新表,但在升级应用程序时也不会丢失其他表中的数据。有人可以告诉我(但如果你也能向我展示一些例子)这是如何完成的以及如何测试它。因为我浏览过论坛,但主要是关于添加新列等的讨论。我认为我必须使用 alter table 以某种方式完成此操作,但我并不理解所有内容。如果您能告诉我这个过程的步骤,我将非常感激。我已经使用了 DBAdapter 类扩展 SQLiteOpenHelper。接受我的问题并尽快给我解决方案。
Friends,
I have an existing apps published and during an upgrade, I want to add a new table to my database, but also not lose the data from the other tables when upgrading the application. Can someone tell me, (but if you could show me some example also) of how this is done and how to test it. Because I've looked through the forums but mainly there are discussions about adding a new column etc. I figured that I have to do it somehow with alter table, but I did not understand everything. If you can tell me the steps of this process I would really appreciate it.I have used DBAdapter class extends SQLiteOpenHelper.Accept my question and asap give me solution..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一切都发生在您的类
DBAdapter
中。在那里,您必须实现一个方法onUpgrade
,它将新表添加到数据库中。这是执行此操作的框架:您可以查看类 的文档SQLiteOpenHelper
Everything happens in your class
DBAdapter
. There you must implement a methodonUpgrade
which adds your new table to the database. Here is a skeleton for doing this:You may look at the documentation of the class SQLiteOpenHelper