You can use the begintransaction () method of sqlitedatabase to start a transaction,ProgramWhen you run the endtransaction () method, the system checks whether the transaction flag is successful. If the settransactionsuccessful () method is called before the program runs to the endtransaction () method, the transaction is committed if the flag of the transaction is set to successful, if the settransactionsuccessful () method is not called, the transaction is rolled back.
Sqlitedatabase DB = dbopenhelper. getwritabledatabase ();
// Start the transaction DB. begintransaction (); Try { Db.exe csql ("", new object [] {}); Db.exe csql ("", new object [] {}); // Set the transaction flag to successful. When the transaction ends, the transaction will be committed. DB. settransactionsuccessful (); } Finally { // End the transaction DB. endtransaction (); }