beginTransaction(), endTransaction(), and setTransactionSuccessful(). What exactly do they do?

前端 未结 2 578
陌清茗
陌清茗 2021-02-07 08:56

I have to provide synchronization when inserting, querying, updating and deleting items from a database. As far as I understand beginTransaction() and beginTr

2条回答
  •  鱼传尺愫
    2021-02-07 09:20

    Yes, it makes app smooth.Because SQLite consider one cursor as one transaction, so if we use begin transaction() before we insert big amount of data, then use setTransactionSuccessful() second, then endTransaction() in finally, SQLite will consider this insert event as one transaction, instead of hundreds of transactions.

提交回复
热议问题