public synchronized void insert(final List<City> list) { try { TransactionManager.callInTransaction( DatabaseHelper.getInstance(mContext).getConnectionSource(), new Callable<Void>() { @Override public Void call() throws Exception { for (City city : list) { mDao.createOrUpdate(city); } return null; } }); } catch (SQLException e) { e.printStackTrace(); } }
private CityDB(Context context) { mContext = context; mDao = DatabaseHelper.getInstance(context).getDao(City.class); }