What about multithreading in Android SQLite?

前端 未结 6 1062
旧巷少年郎
旧巷少年郎 2021-02-05 16:06

In my app I\'ve got to implement some UI and Sync service. It runs in the background and updates data. Sync service is not very simple, it uses multithreading.

So, here

6条回答
  •  北荒
    北荒 (楼主)
    2021-02-05 16:22

    So, finally came out to the solution. Here it is.

    I read some forums, google groups and found out that sqlite database should be opened only once. So, I implemented this using singleton.

    Also, I implemented some db code to synchronize all write operations (to prevent many threads execute write operations at one time). And I don't care about opening cursors, reading from them.

    After some days testing I've got no error reports from my users, so I think this works

    In my previous work I opened sqlite database many times across the application, that was the problem.

提交回复
热议问题