下面是代码,目前我正在使用,但我正在寻找一种方法来加速我的插入,并且第一次插入100行以上...任何想法?Android:使用SQLite插入批量数据(一次)
public class SQLiteAdapter {
private SQLiteHelper sqLiteHelper;
private SQLiteDatabase sqLiteDatabase;
private Context context;
public SQLiteAdapter(Context c){
context = c;
}
public long insert(String empId, String name......)
{
ContentValues contentValues = new ContentValues();
contentValues.put(KEY_EMP_ID, empId);
.....................
.....................
.....................
return sqLiteDatabase.insert(KEY_TABLE, null, contentValues);
}
public void InsertReciters()
{
//currently, this is how i am doing, how can i speed up inserting the rows in to db?
//i have 100+ rows ..........
this.insert("ac123", ................);
this.insert("ac133", ................);
this.insert("ac143", ................);
this.insert("ac153", ................);
this.insert("ac163", ................);
.................
.................
}
}
您可以使用预填充数据库:http://stackoverflow.com/a/9109728/265167 – 2012-03-27 06:44:45
谢谢阿古柏1+ – 2012-03-27 16:19:38
准备好的发言和交易:HTTP://计算器。 com/a/29797229/3681880 – Suragch 2015-04-27 08:15:31