Sunday, 15 May 2011

android - does getWritableDatabase() effect transactions -



android - does getWritableDatabase() effect transactions -

as understand it, calling sqliteopendhelper.getwritabledatabase() returns same instance of sqlitedatabase. transaction associated remain unaffected?

assume single threaded environment , utilize singleton sqliteopenhelper instance. suppose have long transaction :

i phone call sqlitedatabase.begintransaction() once. dao1 constructor calls sqliteopendhelper.getwritabledatabase(). dao1 method performs crud operation on it. dao2 constructor calls sqliteopendhelper.getwritabledatabase(). dao2 method performs crud operation on it. ...on , on i phone call sqlitedatabase.endtransaction() once.

do dao operations executed within single transaction? not figure out source if multiple calls getwritabledatabase() effects transactions in way.

yes; same database connection (i.e., same sqlitedatabase object) uses single transaction, , operations done through in same transaction.

please note sqlitedatabase supports nested transactions.

android sqlite android-sqlite

No comments:

Post a Comment