Нужно вставить объемные данные в SQLite (100-500 записей одновременно ... по 7 столбцов, в каждой строке будет 7 значений)
Использование statment.bind
Plz предлагает, если что-то не так, и hw реализовать с помощью пакетной вставки db.execSQL
SQLiteDatabase db = DBHelper.getWritableDatabase();
String str = "INSERT INTO DBAdapter.KEY_BD1_DB_NAME(a, b, c, d, e, f,g) VALUES(?, ?, ?, ?, ?, ?,?)";
SQLiteStatement statement = db.compileStatement(str);
db.beginTransactionNonExclusive();
try {
for (int i=0;i<arraylist.length;i++)
{
statement.bindLong(1, id);
statement.bindLong(2, alist[i]);
statement.bindLong(3, blist[i]);
statement.bindString(4, strTStamp[0]);
statement.bindString(5, strTStamp[1]);
statement.bindLong(6, j);
statement.bindLong(7, tstamp);
if (alist.size>100)
{
if(count==100)
{
statement.executeInsert();
statement.clearBindings();
count=0;
}
else
{
count++;
}
}
}
statement.executeInsert();
statement.clearBindings();
db.setTransactionSuccessful();
Log.d("INSERT","Done");
return true;
} catch (SQLException ex) {
Log.w("SqlErr", "At kkr : " + ex.toString());
return false;
}finally {
db.endTransaction();
db.close();
}