SQLite simultaneous reading and writing

后端 未结 4 1620
谎友^
谎友^ 2020-11-30 00:59

I\'ve read a lot of topics, but can\'t figure out answer for question: is it possible to read and write simultaneous?

I have background thread that updates some data

4条回答
  •  孤街浪徒
    2020-11-30 01:14

    Starting with API 11 Android has support for WAL mode. It keeps original data untouched during transaction, so other threads can read when transaction is running. You can check my article for more details about WAL mode:

    http://www.skoumal.net/en/parallel-read-and-write-in-sqlite/

    You should also avoid running database queries in UI thread. It could always become sluggish and block your UI.

提交回复
热议问题