【发布时间】:2011-07-15 17:18:34
【问题描述】:
我有一个处理我大学打印机的活动。打印机可以通过 Internet 下载,然后存储在 SQLite 数据库中。问题是,必须创建大约 500 个数据库条目来存储它们,这对我的代码来说非常耗时(在 Google Nexus S 上大约需要 30 秒)。我这样做的代码是这样的:
printerDB = new PrinterListOpenHelper(this);
SQLiteDatabase db = printerDB.getWritableDatabase();
db.execSQL("INSERT INTO destination (id, destination) VALUES(1,'BSAC240');");
db.execSQL("INSERT INTO destination (id, destination) VALUES(2,'BSAD152');");
...
这之后是大约。 500 个类似的行。我也试着用一个来做到这一点
db.rawQuerry("INSERT INTO destination (id, destination) VALUES(1,'BSAC240');
INSERT INTO destination (id, destination) VALUES(2,'BSAD152');.......");
但实际上只执行了第一个 INSERT 语句。
有人知道提高效率的诀窍吗?还是 Android 数据库真的那么慢?
非常感谢您的帮助! 西蒙
【问题讨论】:
标签: android sqlite performance