How to use transactions SQlite? Maybe I was looking bad, but I did not find how to do it right. I execute everything in AsyncTask. Here is the code:
DbOpenHelper dbOpenHelper = new DbOpenHelper(MainActivity.this); SQLiteDatabase db = dbOpenHelper.getWritableDatabase(); ContentValues qcv = new ContentValues(); db.beginTransaction(); try { for (int k = 0; k < 10; k++) { qcv.put(DbOpenHelper.ID, 200 + k); qcv.put(DbOpenHelper.KEY1, "value1"); qcv.put(DbOpenHelper.KEY2, "value2"); db.insert(DbOpenHelper.TABLE2_NAME, null, qcv); db.setTransactionSuccessful(); } } finally { db.endTransaction(); }