如何在Android上的应用程序升级后更新表模式?应用程序、模式、如何在、Android

2023-09-04 07:08:18 作者:刘海遮住的额头

我有一个未完成的应用程序,但我想现在讨论它的未来的更新。

I have an unfinished application, but I want to address now the future update of it.

假设我的应用程序进行了升级,所以当启动时,检测到数据库模式已经过时。因此,对于每个表都有根据版本号为新的模式进行更新,而preserving的所有数据。

Suppose my app was upgraded, so when starts, detects that the database schema is outdated. So for each table has to update according to version number to the new schema while preserving all data.

我曾经读过关于Android的SQLite数据库有一定的版本号,并自动更新的东西,但我没有找到一个例子这一具体问题。

I've read somewhere that on Android the SQLite database have some version number, and auto update stuff, but I didn't found an example for this specific issue.

如何实现这一点的Andr​​oid应用程序,使用SQLite数据库?

How can this be accomplished on an Android app, using SQLite databases?

有没有存储在Android的SQLite数据库表的每一个具体的版本号?如果是这样,我怎么能理解它,然后用我的上述目的?

Is there a specific version number per table stored on Android SQLite databases? If so, how can I read it, and use for my above purpose?

推荐答案

SQLiteOpenHelper是你的朋友在这里。

SQLiteOpenHelper is your friend here.

见source在记事本的例子;您需要提供的onCreate onUpgrade 的方法。

See the source for the Notepad example; you need to supply onCreate and onUpgrade methods.