During development, a lot of Preset information is often stored in the database at a time. It is a headache for new users.
It is impossible to use the for loop to execute the inert statement once and again. The efficiency is very low. It takes a long time to store 500 pieces of data on the mobile phone.
By searching online materials, there are roughlyThree methods;
1, Through ";" spell string, such as: "insert into table values (x, x, x); insert into table values (x, x, x ); insert into table values (x, x, x );"
2Insert into points (x_axis, y_axis, img_id, width, height) Select 150,150, 40 Union all select 50, 50, 40 Union all select, 50, 40;
3, Import data through XML, and then ...... I looked at this and went straight away.
Conclusion:
For the first method, I successfully simulated it on the computer, but the same statement can only be executed on the Android phone! I tried it many times and had no words. I had to give up.
Method 2Successful. However, if there are many records, you have to write a long statement, but the length is much shorter than that of the first one. ^_^. The experiment I did was to execute 55 pieces of data, which took a short time and could not be affected.
The third method is not tested. The reason is: first, write the records one by one into XML (this workload is not small). The second step is to read the data in XML, and the third step is to insert the data into the database through the second method. The purpose of writing data into XML is to saveCodeSpace. In fact, it is not cost-effective. This method can be used if there is a lot of data, just to save the code space.
If there are other methods, they are stored procedures. However, SQLite does not support complex SQL statements, including stored procedures, or ultra-large-scale data storage.