开发者

Android - Exception when updating table in database

I get one exception "SQLiteException: cannot commit - no transaction is active". This exception is occur when i try to update my table in DataBase . I don't know why this exception is occur & what was the meaning of this exception. So if any one know then please tell me how I can resolve this exception. In code when I replace update query to insert query then no error occur. My update query is like

e.g

ContentValues cVal=new ContentValues();
cVal.put("search", 0);
int count=sqLiteDatabaseWrite.update("TableName", cVal, null,null);

OR also try this

sqLiteDatabaseWrite.execSQL("update TableName set search=0");

In both case error occur. Here I print my logcat.

Thank You

 android.database.sqlite.SQLiteException: cannot commit - no transaction is active
     at android.database.sqlite.SQLiteStatement.native_executeSql(Native Method)
     at android.database.sqlite.SQLiteStatement.executeUpdateDelete(SQLiteStatement.java:89)
     at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1928)
     at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1859)
     at android.database.sqlite.SQLiteDatabase.endTransaction(SQLiteDatabase.java:683)
     at android.database.sqlite.SQLiteStatement.releaseAndUnlock(SQLiteStatement.java:266)
     at android.database.sqlite.SQLiteStatement.executeUpdateDelete(SQLiteStatement.java:96)
     at android.database.sqlite.SQLiteDatabase.updateWithOnConflict(SQLiteDatabase.java:1824)
     at android.database.sqlite.SQLiteDatabase.update(SQLiteDatabase.java:1775)
     at com.ScentSational.SearchProducts.insertIntoProductTable(SearchProducts.java:609)
     at com.ScentSational.SearchProducts.parseSearchXml(SearchProducts.j开发者_开发问答ava:434)
     at com.ScentSational.SearchProducts$Async_SearchParsing.doInBackground(SearchProducts.java:780)
     at com.ScentSational.SearchProducts$Async_SearchParsing.doInBackground(SearchProducts.java:1)
     at android.os.AsyncTask$2.call(AsyncTask.java:252)
     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
     at java.util.concurrent.FutureTask.run(FutureTask.java:137)
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1081)
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:574)
     at java.lang.Thread.run(Thread.java:1020)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜