不能从第2版降级数据库1,即使重新安装和重新运行 [英] Can't downgrade database from version 2 to 1 even after fresh install and re-run

查看:224
本文介绍了不能从第2版降级数据库1,即使重新安装和重新运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在写使用SQLite数据库Android应用程序。

I'm writing an android app using SQLite DB.

我有几个实验,改变从1数据库版本为2。

I had few experiments and changed the DB version from 1 to 2.

然后我的数据库架构趋于稳定,因为我没有松开的应用程序,这是我自己用

Then my DB schema became stable and because i didn't release the app and it's for my own use

我已经决定了的版本改为1了。

I have decided to change the version to 1 again.

我没有新的安装,一切运行良好。

I did fresh install and everything worked fine.

但随后跑第二次抛出这个错误:

But then running for the second time throws this error:

06-05 10:03:35.683: E/AndroidRuntime(9010): android.database.sqlite.SQLiteException: Can't downgrade database from version 2 to 1
06-05 10:03:35.683: E/AndroidRuntime(9010):     at android.database.sqlite.SQLiteOpenHelper.onDowngrade(SQLiteOpenHelper.java:361)

这是为什么呢,毕竟我没有新的安装和DB应该被移除。否?

Why is that, after all I did fresh install and the DB should have been removed as well. No?

我怎样才能改变版本1了吗?

How can i change the version to 1 again?

推荐答案

这异常被抛出以下条件:

This exception is thrown on the following conditions:

  • 您正在运行的code该器件具有2版的数据库文件。
  • 的code请求数据库的版本1(用参数来 SQLiteOpenHelper 的构造函数)
  • onDowngrade()在code不被覆盖。
  • The device that you're running the code on has a database file of version 2.
  • The code is requesting version 1 of the database (with a param to SQLiteOpenHelper constructor)
  • onDowngrade() is not overridden in your code.

您说后一个全新安装code精细工作的第一次。确保有没有其他的code,将撞了相同的数据库文件,以2的版本号了。

You say the code worked fine the first time after a fresh install. Make sure there's no other code that would bump up the version number of the same database file to 2 again.

这篇关于不能从第2版降级数据库1,即使重新安装和重新运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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