[英]Android app taking much time to load data from sqlite
I am making an android app which requires 1200 records to insert and then fetch. 我正在制作一个需要1200条记录才能插入然后获取的android应用。 I am using sqlite as back end.
我正在使用sqlite作为后端。 Everything is working fine but app takes lot of time to load the data at very first time for new installation.
一切工作正常,但应用程序在首次安装时需要花费大量时间来加载数据。 I am using SQLiteOpenHelper class to insert data.
我正在使用SQLiteOpenHelper类插入数据。 Please suggest ways to reduce the time to load the data at very first time.
请提出减少第一次加载数据时间的方法。
EDIT : I resolved my problem:) Here is how? 编辑:我解决了我的问题:)这是怎么回事? My app was taking much time because, I was inserting all the 1200 records at a time.
我的应用程序花费了很多时间,因为我一次插入了所有1200条记录。 Now i changed my code such that it should insert only required data one at a time so it saved my lot of time.
现在,我更改了代码,使其一次只能插入所需的数据,从而节省了很多时间。
Use transactions as explained in this answer and make sure that you are only creating one connection to the SQL database for the transaction(s) 按照此答案中的说明使用事务,并确保仅为事务创建一个到SQL数据库的连接
There should be a significant speed increase 速度应该大大提高
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.