我正在做一个更新和插入review_schedule表。似乎两者的时间都在1到2秒之间,这有点慢。我试过,没有在id字段和date_review字段上设置索引。请注意,我为插入使用预编译语句,但不是更新,因为Gingerbread中不支持更新的编译语句。这里的代码:如何加速Android上的SQLite访问
public long insert(int id, String lastReviewDate, String nextReviewDate) {
this.insertStmt.bindLong(1, id);
this.insertStmt.bindString(2, lastReviewDate);
this.insertStmt.bindString(3, nextReviewDate);
return this.insertStmt.executeInsert();
}
public void updateSRSInfo(int id, String lastReviewDate,
String nextReviewDate) {
ContentValues contentValues = new ContentValues();
contentValues.put("last_review_date", lastReviewDate);
contentValues.put("next_review_date", nextReviewDate);
this.myDataBase.update(DataBaseHelper.WORD_REVIEW_SCHEDULE,
contentValues, "_id=?", new String[] { Integer.toString(id) });
}
任何建议表示赞赏。
为什么downvotes,家伙? –
我不担心。它也发生在我身上。我认为,如果你的问题至少在表面上看起来很糟糕,格式良好并且要求得到满足,那么人们至少应该发表评论来帮助我们改进(这就是整个观点,不是吗?)。提醒你,我不知道你的问题的解决方案,只是来到这里为你添加一个,祝你好运! – davidcesarino
程序是否使应用程序无响应?如果是这种情况,也许你可以将操作移到不同的线程中。 – mbwasi