Realm non supporta ancora i GroupBy. Sappi anche che beginGroup() è in realtà lo stesso di parentesi. Quindi la query è in realtà interpretato come:
// SQL pseudo code
SELECT * FROM Account WHERE (date = MONTH(date))
Nel regno che avrebbe dovuto fare qualcosa di simile per selezionare un solo mese:
// Between is [ monthStart, monthEnd ]
Date monthStart = new GregorianCalendar(2015, 5, 1).getTime();
Date monthEnd = new GregorianCalendar(2015, 6, 1).getTime() - 1;
accounts = realm.where(Account.class).between("date", monthStart, monthEnd).findAll();
o qualcosa di simile per rilevare quando un mese cambia
// pseudo code. You might want to use Calendar instead
accounts = realm.where(Account.class).findAllSorted("date")
Iterator<Account> it = accounts.iterator();
int previousMonth = it.next().getDate().getMonth();
while (it.hasNext) {
int month = it.next().getDate().getMonth();
if (month != previousMonth) {
// month changed
}
previousMonth = month;
}
fonte
2015-05-26 04:57:42
grazie mille per la tua risposta rapida. prima funziona per me. – schwertfisch