@Override public void onStart(Intent intent, int startId) { super.onStart(intent, startId); // get today's day of month to query overhead of this same day Calendar cal = Calendar.getInstance(); cal.setTime(new Date()); int dayOfMonth = cal.get(Calendar.DAY_OF_MONTH); // query realm for overhead to be created on this day RealmResults<OverheadModel> overheadsList = realm.where(OverheadModel.class).equalTo("dayOfMonth", dayOfMonth).findAll(); // Get iterator Iterator<OverheadModel> iterator = overheadsList.iterator(); // Create new transaction for each result while (iterator.hasNext()) { OverheadModel overhead = iterator.next(); TransactionModel transaction = new TransactionModel(-1); transaction.setTransactionType(CreateTransactionActivity.TRANSACTION_TYPE_EXPENSE); transaction.setPrice(overhead.getPrice()); transaction.setCategory(realm.copyFromRealm(overhead.getCategory())); transaction.setFromAccount(realm.copyFromRealm(overhead.getFromAccount())); transaction.setDate(cal.getTime()); transaction.setComment(overhead.getComment()); transaction.setPending(false); transaction.setDueToOrBy(0); transaction.setDueName(null); transactionRepository.saveTransaction(transaction); } // Set alarm for next month this.setUpNewAlarm(); // Kill service stopSelf(); }