Efficient batch SQL query execution on Android, for upgrade database

后端 未结 2 1528
予麋鹿
予麋鹿 2020-12-30 14:31

As we Android developers know, the SQLiteDatabase execSQL method can execute only one statement.

The doc says:

Execute a single

相关标签:
2条回答
  • 2020-12-30 15:00

    I think what you have is the only way to load those 1000 records, now, as far as deploying that DB with your apk file, check out this post:

    http://www.helloandroid.com/tutorials/how-have-default-database

    0 讨论(0)
  • 2020-12-30 15:20

    How do I insert these efficiently?

    Use transaction:

        db.beginTransaction();
        try {
            for(;;) {
                db.execSQL(...);
                }
            db.setTransactionSuccessful();
        } finally {
            db.endTransaction();
        }
    
    0 讨论(0)
提交回复
热议问题