Previously used database was always executed directly, Db.execute ().
Today look at the company 1.0 of the source code and learned a logic,
Securesqlitedatabase db = null;
Try {
db = mopenhelper. OpenDatabase ();
Db.begintransaction ();
Try {
TODO Data operations
};
Operations to be performed by DB
Db.update (mstdataentry. table_name, values, Whereclause, Whereargs);
Db.settransactionsuccessful ();
} finally {
Db.endtransaction ();
}
} finally {
mopenhelper. Close ();
}
When the program executes to the Endtransaction () method, it checks whether the flag of the transaction is successful,
If the program executes to Endtransaction () before calling the Settransactionsuccessful () method to set the transaction flag as successful, the transaction is committed.
If the Settransactionsuccessful () method is not called, the transaction is rolled back.
This will enable us to perform the operation that the transaction is determined to execute before returning, and switching off the db.