4

前段时间我发布了这个问题: Android onUpgrade Database 导致 IllegalStateException

灵魂是在数据库升级时停止并重新启动事务:

public void onUpgrade(SQLiteDatabase db,
        int oldVersion, int newVersion) {

db.endTransaction();
//updgading the db
db.beginTransaction();
}

这在我的测试系统上工作,但现在我从我的生活系统中获得了永久的错误跟踪。似乎在大多数系统上它都在工作,但不是在一些系统上。

java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:278)
at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
Caused by: java.lang.IllegalStateException: no transaction pending
at net.sqlcipher.database.SQLiteDatabase.endTransaction(SourceFile:640)
at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SourceFile:128)
at com.myApp.j.q(SourceFile:339) ...

这里有什么问题?谢谢塔塔

编辑:这是发生崩溃的地方。SQLiteOpenHelper.getWritableDatabase(SourceFile:128)

int version = db.getVersion();
            if (version != mNewVersion) {
                db.beginTransaction();
                try {
                    if (version == 0) {
                        onCreate(db);
                    } else {
                        onUpgrade(db, version, mNewVersion);
                    }
                    db.setVersion(mNewVersion);
                    db.setTransactionSuccessful();
                } finally {
                    db.endTransaction(); //L. 128 crash
                }
            }
4

0 回答 0