public synchronized void updateStop(ArrayList<StopBean> beanList){
SQLiteDatabase db = getWritableDatabase();
String query = "DELETE FROM 'stop'";
db.execSQL(query);
for(StopBean bean : beanList){
String atco_code = bean.getAtco_code();
String name = bean.getName();
String locality = bean.getLocality();
String bearing = bean.getBearing();
String latitude = bean.getLatitude()+"";
String longitude = bean.getLongitude()+"";
ContentValues values = new ContentValues();
values.put("atco_code", atco_code);
values.put("name", name);
values.put("locality", locality);
values.put("bearing", bearing);
values.put("latitude", latitude);
values.put("longitude", longitude);
db.insert("stop", null, values);
}
db.close();
}
Currently our application inserts 4,000 rows via the method above. The problem with this method is that it takes 10-15 seconds to actually execute. Clearly this is far too long for a simple 4,000 row insert.
How can I change this method so that it vastly speeds up the execution time of these inserts?