Android boosts SQLite's high-volume data storage efficiency

Source: Internet
Author: User

It is time-consuming to insert in SQLite because no transactions are used, and the default is to use each insert once

A transaction so that if you insert 1000 data, it is time consuming to open 1000 transactions, so we can use the code to control transactions by manually opening and closing.

?
1 2 3 4 5 6 7 8 9 10 11 12 public void insertAll(String databaseName,             ArrayList<ContentValues> valuesArr) {         SQLiteDatabase db = getWritableDatabase();         db.beginTransaction();         for (ContentValues val : valuesArr) {             db.insert(databaseName, null, val);         }          db.setTransactionSuccessful();         db.endTransaction();         db.close();     }

With this open transaction, the time to insert the data will be significantly improved.

But improving efficiency can also be considered in other ways, such as database correlation, which still needs to be studied

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.