Android Sqlite Performance

前端 未结 3 1050
遇见更好的自我
遇见更好的自我 2020-12-05 01:33

I have been doing some experiments to measure sqlite performance on android. I was disappointed a little bit with the results. What i did was inserting 10.000 queries to ta

3条回答
  •  独厮守ぢ
    2020-12-05 02:02

    Well, you have so many records and for every record you call getWritableDatabase() and then insert it, which is bad for performance.

    You need to use transactions. Look at this question Android SQLite database: slow insertion. Basically you need to call beginTransaction(), do your insertions and then call setTransactionSuccessful() preceded by endTransaction(). You will be amazed to see how much performance gain you will get with this.

提交回复
热议问题