Пример #1
0
  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();
    }
  }
Пример #2
0
 private CityDB(Context context) {
   mContext = context;
   mDao = DatabaseHelper.getInstance(context).getDao(City.class);
 }