我正在使用Active Android
以在我的 android 应用程序中执行 sqllite 操作。以下是一个模型类。
@Table(name="books")
public class Books extends Model {
@Column(name = "bookId")
public String bookId;
@Column(name = "bookName")
public String bookName;
}
我想为此添加一个新列。所以我按照Active Android's Schema Migration Doc上的说明进行操作。
一个。更新了AA_DB_VERSION
湾。在中添加了一个新的 sql 文件assets/migrations
然后当我运行我的应用程序时,我得到以下异常
1553-1553/com.hannan.delivery E/SQLiteLog﹕ (21) API called with NULL prepared statement
1553-1553/com.hannan.delivery E/SQLiteLog﹕ (21) misuse at line 63241 of [00bb9c9ce4]
java.lang.RuntimeException: Unable to create application com.hannan.delivery.MyApplication: android.database.sqlite.SQLiteException: not an error (code 0)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4154)
at android.app.ActivityThread.access$1300(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1255)
....
Caused by: android.database.sqlite.SQLiteException: not an error (code 0)
at android.database.sqlite.SQLiteConnection.nativeExecuteForChangedRowCount(Native Method)
at android.database.sqlite.SQLiteConnection.executeForChangedRowCount(SQLiteConnection.java:727)
at android.database.sqlite.SQLiteSession.executeForChangedRowCount(SQLiteSession.java:754)
at android.database.sqlite.SQLiteStatement.executeUpdateDelete(SQLiteStatement.java:64)
at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1665)
at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1594)
at com.activeandroid.DatabaseHelper.executeSqlScript(DatabaseHelper.java:180)
at com.activeandroid.DatabaseHelper.executeMigrations(DatabaseHelper.java:150)
at com.activeandroid.DatabaseHelper.onUpgrade(DatabaseHelper.java:74)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:257)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:164)
at com.activeandroid.Cache.openDatabase(Cache.java:102)
at com.activeandroid.Cache.initialize(Cache.java:75)
at com.activeandroid.ActiveAndroid.initialize(ActiveAndroid.java:44)
at com.activeandroid.ActiveAndroid.initialize(ActiveAndroid.java:34)
at com.activeandroid.ActiveAndroid.initialize(ActiveAndroid.java:30)
at com.activeandroid.app.Application.onCreate(Application.java:25)
at com.hannan.delivery.MyApplication.onCreate(MyApplication.java:51)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:999)
...
这是失败的 MyApplication 的 Create 方法。
@Override
public void onCreate() {
super.onCreate();
ActiveAndroid.initialize(this);
}
迁移脚本是:(2.sql)
ALTER TABLE books ADD COLUMN bookAuthor TEXT;
请建议我为什么会收到此错误。